userver: /data/code/userver/libraries/proto-structs/include/userver/proto-structs/json.hpp File Reference
Loading...
Searching...
No Matches
json.hpp File Reference

Detailed Description

Utilities for converting protobuf structs to/from formats::json::Value.

Definition in file json.hpp.

Go to the source code of this file.

+ This graph shows which files directly or indirectly include this file:

Namespaces

namespace  proto_structs
 Top namespace for the proto-structs library.
 

Functions

template<typename TStruct>
requires traits::ProtoStruct<std::remove_cvref_t<TStruct>>
formats::json::Value proto_structs::StructToJson (TStruct &&obj, const protobuf::json::PrintOptions &options)
 Converts protobuf struct obj to formats::json::Value. Conversion is performed by converting the protobuf struct to an intermediate protobuf message and then converting the message to formats::json::Value.
 
template<typename TStruct>
requires traits::ProtoStruct<std::remove_cvref_t<TStruct>>
std::string proto_structs::StructToJsonString (TStruct &&obj, const protobuf::json::PrintOptions &options)
 Converts protobuf struct obj to an std::string, containing the JSON representation of the struct. Conversion is performed by converting the protobuf struct to an intermediate protobuf message, then converting the message to formats::json::Value, and finally converting the value to a string.
 
template<typename TStruct>
requires traits::ProtoStruct<std::remove_cvref_t<TStruct>>
TStruct proto_structs::JsonToStruct (const formats::json::Value &json, const protobuf::json::ParseOptions &options)
 Converts json to protobuf struct of type TStruct. Conversion is performed by converting the formats::json::Value to an intermediate protobuf message and then converting the message to a protobuf struct.
 
template<typename TStruct>
requires traits::ProtoStruct<std::remove_cvref_t<TStruct>>
TStruct proto_structs::JsonStringToStruct (std::string_view json_string, const protobuf::json::ParseOptions &options)
 Converts json_string to protobuf struct of type TStruct. Conversion is performed by first converting the string to formats::json::Value, then converting the value to an intermediate protobuf message, and finally converting the message to a protobuf struct.