userver: userver/ugrpc/proto_json.hpp Source File
Loading...
Searching...
No Matches
proto_json.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/ugrpc/proto_json.hpp
4/// @brief Utilities for conversion Protobuf -> Json
5
6#include <google/protobuf/util/json_util.h>
7
8#include <userver/formats/json.hpp>
9#include <userver/formats/json/serialize.hpp>
10
11USERVER_NAMESPACE_BEGIN
12
13namespace ugrpc {
14
15/// @brief Returns formats::json::Value representation of protobuf message
16/// @throws SerializationError
17formats::json::Value MessageToJson(const google::protobuf::Message& message);
18
19/// @brief Converts message to human readable string
20std::string ToString(const google::protobuf::Message& message);
21
22/// @brief Returns Json-string representation of protobuf message
23/// @throws formats::json::ConversionException
24std::string ToJsonString(const google::protobuf::Message& message);
25
26} // namespace ugrpc
27
28namespace formats::serialize {
29
30json::Value Serialize(const google::protobuf::Message& message,
31 To<json::Value>);
32
33} // namespace formats::serialize
34
35USERVER_NAMESPACE_END