userver: /data/code/userver/libraries/protobuf/include/userver/protobuf/json/convert.hpp File Reference
Loading...
Searching...
No Matches
convert.hpp File Reference

Detailed Description

Utilities for converting protobuf messages to/from JSON ValueBuilder/Value according to ProtoJSON format.

Definition in file convert.hpp.

Go to the source code of this file.

#include <cstddef>
#include <string>
#include <string_view>
#include <type_traits>
#include <google/protobuf/message.h>
#include <userver/formats/json/value.hpp>
#include <userver/formats/json/value_builder.hpp>
#include <userver/formats/parse/to.hpp>
#include <userver/formats/serialize/to.hpp>
#include <userver/protobuf/json/convert_options.hpp>
#include <userver/protobuf/json/exceptions.hpp>
This graph shows which files directly or indirectly include this file:

Namespaces

namespace  protobuf
 Top namespace for the userver protobuf library.
namespace  protobuf::json
 Top namespace for the protobuf JSON utilities.
namespace  formats
 Value formats representation, parsing and serialization.
namespace  formats::serialize
 Common serializers.
namespace  formats::parse
 Generic parsers and converters.

Functions

formats::json::ValueBuilder protobuf::json::MessageToJsonBuilder (const ::google::protobuf::Message &message, const PrintOptions &options={})
 Converts protobuf message to JSON ValueBuilder.
formats::json::Value protobuf::json::MessageToJson (const ::google::protobuf::Message &message, const PrintOptions &options={})
 Converts protobuf message to JSON Value.
void protobuf::json::JsonToMessage (const formats::json::Value &json, ::google::protobuf::Message &message, const ParseOptions &options={})
 Converts json to protobuf message.
template<typename T>
requires (std::is_base_of_v<::google::protobuf::Message, T> && !std::is_same_v<::google::protobuf::Message, T>)
T protobuf::json::JsonToMessage (const formats::json::Value &json, const ParseOptions &options={})
 Converts json to protobuf message of type T.
void protobuf::json::JsonStringToMessage (std::string_view json_string, ::google::protobuf::Message &message, const ParseOptions &options={})
 Parses json_string into protobuf message.
template<typename T>
requires (std::is_base_of_v<::google::protobuf::Message, T> && !std::is_same_v<::google::protobuf::Message, T>)
T protobuf::json::JsonStringToMessage (std::string_view json_string, const ParseOptions &options={})
 Parses json_string into a protobuf message of type T.
std::string protobuf::json::MessageToJsonString (const ::google::protobuf::Message &message, const PrintOptions &options={})
 Serializes protobuf message to a JSON string.
std::string protobuf::json::MessageToDebugString (const ::google::protobuf::Message &message, std::size_t limit)
 Serializes protobuf message to a JSON string for debugging/logging, stopping early once limit bytes have been produced.
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 ProtoJSON format in the same way as protobuf::MessageToJson called with a default options.
template<typename TMessage, typename = std::enable_if_t< std::is_base_of_v<::google::protobuf::Message, TMessage> && !std::is_same_v<::google::protobuf::Message, TMessage>>>
TMessage formats::parse::Parse (const json::Value &value, To< TMessage >)
 Conversion from formats::json::Value to google::protobuf::Message. Uses the ProtoJSON format in the same way as protobuf::JsonToMessage called with a default options.