Top namespace for the protobuf JSON utilities.
Classes | |
| class | ConversionError |
| JSON/protobuf conversion error. More... | |
| class | ConversionErrorBase |
| Base exception type for JSON/protobuf conversion errors. More... | |
| class | ConversionErrorInfo |
| JSON/protobuf conversion error information. More... | |
| class | JsonError |
| Base exception type for JSON utilities. More... | |
| struct | ReadOptions |
JSON read options which affect how JSON Value is converted to a protobuf message. More... | |
| struct | WriteOptions |
JSON write options which affect how protobuf message is converted to a JSON ValueBuilder/Value. More... | |
Typedefs | |
| using | ReadErrorInfo = ConversionErrorInfo< ReadErrorCode > |
| JSON read error information. | |
| using | WriteErrorInfo = ConversionErrorInfo< WriteErrorCode > |
| JSON write error information. | |
| using | ReadError = ConversionError< ReadErrorCode > |
| JSON read error. | |
| using | WriteError = ConversionError< WriteErrorCode > |
| JSON write error. | |
Enumerations | |
| enum class | ReadErrorCode { kUnknownField = 1 , kUnknownEnum = 2 , kMultipleOneofFields = 3 , kInvalidType = 4 , kInvalidValue = 5 } |
| JSON read error code. More... | |
| enum class | WriteErrorCode { kInvalidValue = 1 } |
| JSON write error code. More... | |
Functions | |
| formats::json::ValueBuilder | MessageToJsonBuilder (const ::google::protobuf::Message &message, const WriteOptions &options={}) |
Converts protobuf message to JSON ValueBuider. | |
| void | JsonToMessage (const formats::json::Value &json, const ReadOptions &options, ::google::protobuf::Message &message) |
| Converts json to protobuf message . | |
| formats::json::Value | MessageToJson (const ::google::protobuf::Message &message, const WriteOptions &options={}) |
Converts protobuf message to JSON Value. | |
| template<typename T , typename = std::enable_if_t< std::is_base_of_v<::google::protobuf::Message, T> || !std::is_same_v<::google::protobuf::Message, T>>> | |
| T | JsonToMessage (const formats::json::Value &json, const ReadOptions &options={}) |
Converts json to protobuf message of type T. | |
| using protobuf::json::ReadError = typedef ConversionError<ReadErrorCode> |
JSON read error.
Definition at line 126 of file exceptions.hpp.
| using protobuf::json::ReadErrorInfo = typedef ConversionErrorInfo<ReadErrorCode> |
JSON read error information.
Definition at line 83 of file exceptions.hpp.
| using protobuf::json::WriteError = typedef ConversionError<WriteErrorCode> |
JSON write error.
Definition at line 129 of file exceptions.hpp.
| using protobuf::json::WriteErrorInfo = typedef ConversionErrorInfo<WriteErrorCode> |
JSON write error information.
Definition at line 86 of file exceptions.hpp.
|
strong |
JSON read error code.
Definition at line 17 of file exceptions.hpp.
|
strong |
JSON write error code.
| Enumerator | |
|---|---|
| kInvalidValue | Protobuf well-known message does not have expected field. Protobuf message field has invalid value. This code can be set when converting well-known message which may have more strict constraints than the typesof their fields (see here for example). |
Definition at line 35 of file exceptions.hpp.
| void protobuf::json::JsonToMessage | ( | const formats::json::Value & | json, |
| const ReadOptions & | options, | ||
| ::google::protobuf::Message & | message | ||
| ) |
Converts json to protobuf message .
| ReadError | if reading protobuf message from JSON has failed |
| MemberMissingException | is json holds nothing The conversion is perfomed according to ProtoJSON specification. |
proto2 syntax is not fully supported and tested. At least extension fields and required label are not supported, but also some other proto2-specific parts of the syntax may not be correctly handled. Definition at line 17 of file convert.cpp.
| T protobuf::json::JsonToMessage | ( | const formats::json::Value & | json, |
| const ReadOptions & | options = {} |
||
| ) |
Converts json to protobuf message of type T.
| T | protobuf message type |
| ReadError | if reading protobuf message from JSON has failed |
| MemberMissingException | is json holds nothing The conversion is perfomed according to ProtoJSON specification. |
proto2 syntax is not fully supported and tested. At least extension fields and required label are not supported, but also some other proto2-specific parts of the syntax may not be correctly handled. Definition at line 80 of file convert.hpp.
|
inline |
Converts protobuf message to JSON Value.
| WriteError | if writing protobuf message to JSON has failed The conversion is perfomed according to ProtoJSON specification. |
allow_alias enum option is on) then the first alias in the definition order is outputted. proto2 syntax is not fully supported and tested. At least extension fields and required label are not supported, but also some other proto2-specific parts of the syntax may not be correctly handled. Definition at line 47 of file convert.hpp.
| formats::json::ValueBuilder protobuf::json::MessageToJsonBuilder | ( | const ::google::protobuf::Message & | message, |
| const WriteOptions & | options = {} |
||
| ) |
Converts protobuf message to JSON ValueBuider.
| WriteError | if writing protobuf message to JSON has failed The conversion is perfomed according to ProtoJSON specification. |
allow_alias enum option is on) then the first alias in the definition order is outputted. proto2 syntax is not fully supported and tested. At least extension fields and required label are not supported, but also some other proto2-specific parts of the syntax may not be correctly handled. Definition at line 10 of file convert.cpp.