Class JsonFormatter.Settings (3.15.8)

public sealed class Settings : object

Settings controlling JSON formatting.

Inheritance

Object > JsonFormatter.Settings

Namespace

Google.Protobuf

Assembly

Google.Protobuf.dll

Constructors

Settings(Boolean)

public Settings(bool formatDefaultValues)

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

Parameter
NameDescription
formatDefaultValuesBoolean

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

Settings(Boolean, TypeRegistry)

public Settings(bool formatDefaultValues, TypeRegistry typeRegistry)

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

Parameters
NameDescription
formatDefaultValuesBoolean

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

typeRegistryTypeRegistry

The TypeRegistry to use when formatting Any messages.

Properties

Default

public static JsonFormatter.Settings Default { get; }

Default settings, as used by Default

Property Value
TypeDescription
JsonFormatter.Settings

FormatDefaultValues

public bool FormatDefaultValues { get; }

Whether fields which would otherwise not be included in the formatted data should be formatted even when the value is not present, or has the default value. This option only affects fields which don't support "presence" (e.g. singular non-optional proto3 primitive fields).

Property Value
TypeDescription
Boolean

FormatEnumsAsIntegers

public bool FormatEnumsAsIntegers { get; }

Whether to format enums as ints. Defaults to false.

Property Value
TypeDescription
Boolean

TypeRegistry

public TypeRegistry TypeRegistry { get; }

The type registry used to format Any messages.

Property Value
TypeDescription
TypeRegistry

Methods

WithFormatDefaultValues(Boolean)

public JsonFormatter.Settings WithFormatDefaultValues(bool formatDefaultValues)

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

Parameter
NameDescription
formatDefaultValuesBoolean

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

Returns
TypeDescription
JsonFormatter.Settings

WithFormatEnumsAsIntegers(Boolean)

public JsonFormatter.Settings WithFormatEnumsAsIntegers(bool formatEnumsAsIntegers)

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

Parameter
NameDescription
formatEnumsAsIntegersBoolean

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

Returns
TypeDescription
JsonFormatter.Settings

WithTypeRegistry(TypeRegistry)

public JsonFormatter.Settings WithTypeRegistry(TypeRegistry typeRegistry)

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

Parameter
NameDescription
typeRegistryTypeRegistry

The TypeRegistry to use when formatting Any messages.

Returns
TypeDescription
JsonFormatter.Settings