webkit  2cdf99a9e3038c7e01b3c37e8ad903ecbe5eecf1
https://github.com/WebKit/webkit
Classes | Public Member Functions | Properties | List of all members
Google.Protobuf.JsonParser Class Reference

Reflection-based converter from JSON to messages. More...

Classes

class  Settings
 Settings controlling JSON parsing. More...
 

Public Member Functions

 JsonParser (Settings settings)
 Creates a new formatted with the given settings. More...
 
T Parse< T > (string json)
 Parses json into a new message. More...
 
T Parse< T > (TextReader jsonReader)
 Parses JSON read from jsonReader into a new message. More...
 
IMessage Parse (string json, MessageDescriptor descriptor)
 Parses json into a new message. More...
 
IMessage Parse (TextReader jsonReader, MessageDescriptor descriptor)
 Parses JSON read from jsonReader into a new message. More...
 

Properties

static JsonParser Default [get]
 Returns a formatter using the default settings. More...
 

Detailed Description

Reflection-based converter from JSON to messages.

Instances of this class are thread-safe, with no mutable state.

This is a simple start to get JSON parsing 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.)

Constructor & Destructor Documentation

◆ JsonParser()

Google.Protobuf.JsonParser.JsonParser ( Settings  settings)
inline

Creates a new formatted with the given settings.

Parameters
settingsThe settings.

Member Function Documentation

◆ Parse() [1/2]

IMessage Google.Protobuf.JsonParser.Parse ( string  json,
MessageDescriptor  descriptor 
)
inline

Parses json into a new message.

Parameters
jsonThe JSON to parse.
descriptorDescriptor of message type to parse.
Exceptions
InvalidJsonExceptionThe JSON does not comply with RFC 7159
InvalidProtocolBufferExceptionThe JSON does not represent a Protocol Buffers message correctly

◆ Parse() [2/2]

IMessage Google.Protobuf.JsonParser.Parse ( TextReader  jsonReader,
MessageDescriptor  descriptor 
)
inline

Parses JSON read from jsonReader into a new message.

Parameters
jsonReaderReader providing the JSON to parse.
descriptorDescriptor of message type to parse.
Exceptions
InvalidJsonExceptionThe JSON does not comply with RFC 7159
InvalidProtocolBufferExceptionThe JSON does not represent a Protocol Buffers message correctly

◆ Parse< T >() [1/2]

Parses json into a new message.

Template Parameters
TThe type of message to create.
Parameters
jsonThe JSON to parse.
Exceptions
InvalidJsonExceptionThe JSON does not comply with RFC 7159
InvalidProtocolBufferExceptionThe JSON does not represent a Protocol Buffers message correctly
Type Constraints
T :IMessage 
T :new() 

◆ Parse< T >() [2/2]

T Google.Protobuf.JsonParser.Parse< T > ( TextReader  jsonReader)
inline

Parses JSON read from jsonReader into a new message.

Template Parameters
TThe type of message to create.
Parameters
jsonReaderReader providing the JSON to parse.
Exceptions
InvalidJsonExceptionThe JSON does not comply with RFC 7159
InvalidProtocolBufferExceptionThe JSON does not represent a Protocol Buffers message correctly
Type Constraints
T :IMessage 
T :new() 

Property Documentation

◆ Default

JsonParser Google.Protobuf.JsonParser.Default
staticget

Returns a formatter using the default settings.


The documentation for this class was generated from the following file: