Class JsonFormatter.Settings
Settings controlling JSON formatting.
Inheritance
Inherited Members
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 |
|
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 |
|
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 |
|
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 |
|
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 |