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
Name Description
formatDefaultValues Boolean

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
Name Description
formatDefaultValues Boolean

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

public static JsonFormatter.Settings Default { get; }

Default settings, as used by Default

Property Value
Type Description
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
Type Description
Boolean

FormatEnumsAsIntegers

public bool FormatEnumsAsIntegers { get; }

Whether to format enums as ints. Defaults to false.

Property Value
Type Description
Boolean

TypeRegistry

public TypeRegistry TypeRegistry { get; }

The type registry used to format Any messages.

Property Value
Type Description
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
Name Description
formatDefaultValues Boolean

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

Returns
Type Description
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
Name Description
formatEnumsAsIntegers Boolean

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

Returns
Type Description
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
Name Description
typeRegistry TypeRegistry

The TypeRegistry to use when formatting Any messages.

Returns
Type Description
JsonFormatter.Settings