userver: userver/ugrpc/proto_json.hpp File Reference
Loading...
Searching...
No Matches
proto_json.hpp File Reference

Detailed Description

Utilities for conversion Protobuf -> Json.

Definition in file proto_json.hpp.

Go to the source code of this file.

#include <google/protobuf/struct.pb.h>
#include <google/protobuf/util/json_util.h>
#include <userver/formats/json/serialize.hpp>
#include <userver/formats/json/value.hpp>

Namespaces

namespace  ugrpc
 Asynchronous gRPC driver.
 
namespace  formats
 Value formats representation, parsing and serialization.
 
namespace  formats::serialize
 Common serializers.
 
namespace  formats::parse
 Generic parsers and converters.
 

Functions

formats::json::Value ugrpc::MessageToJson (const google::protobuf::Message &message)
 Returns formats::json::Value representation of protobuf message.
 
formats::json::Value ugrpc::MessageToJson (const google::protobuf::Message &message, const google::protobuf::util::JsonPrintOptions &options)
 Returns formats::json::Value representation of protobuf message.
 
std::string ugrpc::ToJsonString (const google::protobuf::Message &message)
 Returns Json-string representation of protobuf message.
 
std::string ugrpc::ToJsonString (const google::protobuf::Message &message, const google::protobuf::util::JsonPrintOptions &options)
 Returns Json-string representation of protobuf message.
 
template<typename Message>
Message ugrpc::JsonToMessage (const formats::json::Value &json)
 Parses Json to a protobuf message. Throws on unknown enum values and unknown fields by default.
 
template<typename Message>
Message ugrpc::JsonToMessage (const formats::json::Value &json, const google::protobuf::util::JsonParseOptions &options)
 Parses Json to a protobuf message. Throws on unknown enum values.
 
template<typename Message>
Message ugrpc::FromJsonString (std::string_view json_string)
 Parses Json to a protobuf message. Throws on unknown enum values and unknown fields by default.
 
template<typename Message>
Message ugrpc::FromJsonString (std::string_view json_string, const google::protobuf::util::JsonParseOptions &options)
 Parses Json to a protobuf message. Throws on unknown enum values.
 
json::Value formats::serialize::Serialize (const google::protobuf::Message &message, To< json::Value >)
 Conversion from any google::protobuf::Message to formats::json::Value. Uses the same format as ugrpc::MessageToJson with its default options.
 
template<typename Message, typename = std::enable_if_t<std::is_base_of_v<google::protobuf::Message, Message>>>
Message formats::parse::Parse (const json::Value &value, To< Message >)
 Conversion from formats::json::Value to google::protobuf::Message. Uses the same format as ugrpc::JsonToMessage with its default options.