webkit
2cdf99a9e3038c7e01b3c37e8ad903ecbe5eecf1
https://github.com/WebKit/webkit
|
Reflection-based converter from messages to JSON. More...
Classes | |
class | Settings |
Settings controlling JSON formatting. More... | |
Public Member Functions | |
JsonFormatter (Settings settings) | |
Creates a new formatted with the given settings. More... | |
string | Format (IMessage message) |
Formats the specified message as JSON. More... | |
void | Format (IMessage message, TextWriter writer) |
Formats the specified message as JSON. More... | |
Static Public Member Functions | |
static string | ToDiagnosticString (IMessage message) |
Converts a message to JSON for diagnostic purposes with no extra context. More... | |
Properties | |
static JsonFormatter | Default [get] |
Returns a formatter using the default settings. More... | |
Reflection-based converter from messages to JSON.
Instances of this class are thread-safe, with no mutable state.
This is a simple start to get JSON formatting working. As it's reflection-based, it's not as quick as baking calls into generated messages - but is a simpler implementation. (This code is generally not heavily optimized.)
|
inline |
Creates a new formatted with the given settings.
settings | The settings. |
Converts a message to JSON for diagnostic purposes with no extra context.
This differs from calling Format(IMessage) on the default JSON formatter in its handling of Any. As no type registry is available in object.ToString calls, the normal way of resolving the type of an Any
message cannot be applied. Instead, a JSON property named is included with the base64 data from the Any.Value property of the message.
The value returned by this method is only designed to be used for diagnostic purposes. It may not be parsable by JsonParser, and may not be parsable by other Protocol Buffer implementations.
message | The message to format for diagnostic purposes. |
|
staticget |
Returns a formatter using the default settings.