<PackageReference Include="Google.Protobuf" Version="3.35.0" />

Google.Protobuf.JsonFormatter

public sealed class JsonFormatter
Reflection-based converter from messages to JSON.
public sealed class Settings

Settings controlling JSON formatting.

public static JsonFormatter Default { get; }

Returns a formatter using the default settings.

public JsonFormatter(Settings settings)

Creates a new formatted with the given settings.

public static string ToDiagnosticString(IMessage message)

Converts a message to JSON for diagnostic purposes with no extra context.

public string Format(IMessage message)

Formats the specified message as JSON.

public string Format(IMessage message, int indentationLevel)

Formats the specified message as JSON.

public void Format(IMessage message, TextWriter writer)

Formats the specified message as JSON.

public void Format(IMessage message, TextWriter writer, int indentationLevel)

Formats the specified message as JSON. When Indentation is not null, start indenting at the specified indentationLevel.

public void WriteValue(TextWriter writer, object value)

Writes a single value to the given writer as JSON. Only types understood by Protocol Buffers can be written in this way. This method is only exposed for advanced use cases; most users should be using Format or Format.

public void WriteValue(TextWriter writer, object value, int indentationLevel)

Writes a single value to the given writer as JSON. Only types understood by Protocol Buffers can be written in this way. This method is only exposed for advanced use cases; most users should be using Format or Format.