Show / Hide Table of Contents

Class JsonFormatter.Settings

Settings controlling JSON formatting.

Inheritance
System.Object
JsonFormatter.Settings
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: Google.Protobuf
Assembly: Google.Protobuf.dll
Syntax
public sealed class Settings

Constructors

Settings(Boolean)

Creates a new JsonFormatter.Settings object with the specified formatting of default values and an empty type registry.

Declaration
public Settings(bool formatDefaultValues)
Parameters
Type Name Description
System.Boolean formatDefaultValues

true if default values (0, empty strings etc) should be formatted; false otherwise.

Settings(Boolean, TypeRegistry)

Creates a new JsonFormatter.Settings object with the specified formatting of default values and type registry.

Declaration
public Settings(bool formatDefaultValues, TypeRegistry typeRegistry)
Parameters
Type Name Description
System.Boolean formatDefaultValues

true if default values (0, empty strings etc) should be formatted; false otherwise.

TypeRegistry typeRegistry

The TypeRegistry to use when formatting Any messages.

Properties

Default

Default settings, as used by Default

Declaration
public static JsonFormatter.Settings Default { get; }
Property Value
Type Description
JsonFormatter.Settings

FormatDefaultValues

Whether fields whose values are the default for the field type (e.g. 0 for integers) should be formatted (true) or omitted (false).

Declaration
public bool FormatDefaultValues { get; }
Property Value
Type Description
System.Boolean

FormatEnumsAsIntegers

Whether to format enums as ints. Defaults to false.

Declaration
public bool FormatEnumsAsIntegers { get; }
Property Value
Type Description
System.Boolean

TypeRegistry

The type registry used to format Any messages.

Declaration
public TypeRegistry TypeRegistry { get; }
Property Value
Type Description
TypeRegistry

Methods

WithFormatDefaultValues(Boolean)

Creates a new JsonFormatter.Settings object with the specified formatting of default values and the current settings.

Declaration
public JsonFormatter.Settings WithFormatDefaultValues(bool formatDefaultValues)
Parameters
Type Name Description
System.Boolean formatDefaultValues

true if default values (0, empty strings etc) should be formatted; false otherwise.

Returns
Type Description
JsonFormatter.Settings

WithFormatEnumsAsIntegers(Boolean)

Creates a new JsonFormatter.Settings object with the specified enums formatting option and the current settings.

Declaration
public JsonFormatter.Settings WithFormatEnumsAsIntegers(bool formatEnumsAsIntegers)
Parameters
Type Name Description
System.Boolean formatEnumsAsIntegers

true to format the enums as integers; false to format enums as enum names.

Returns
Type Description
JsonFormatter.Settings

WithTypeRegistry(TypeRegistry)

Creates a new JsonFormatter.Settings object with the specified type registry and the current settings.

Declaration
public JsonFormatter.Settings WithTypeRegistry(TypeRegistry typeRegistry)
Parameters
Type Name Description
TypeRegistry typeRegistry

The TypeRegistry to use when formatting Any messages.

Returns
Type Description
JsonFormatter.Settings
Back to top