userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
object_conv.cpp
1
#
include
<
userver
/
proto
-
structs
/
io
/
userver
/
formats
/
json
/
object_conv
.
hpp
>
2
3
#
include
<
google
/
protobuf
/
struct
.
pb
.
h
>
4
5
#
include
<
userver
/
proto
-
structs
/
io
/
context
.
hpp
>
6
#
include
<
userver
/
protobuf
/
json
/
convert
.
hpp
>
7
8
USERVER_NAMESPACE_BEGIN
9
10
namespace
proto_structs::
io
{
11
12
formats::json::Object ReadProtoStruct(
13
ReadContext& ctx,
14
To<formats::json::Object>,
15
const
::google::protobuf::Struct& msg
16
) {
17
try
{
18
return
formats::json::Object{protobuf::json::MessageToJson(msg, protobuf::json::PrintOptions{})};
19
}
catch
(
const
protobuf::json::PrintError& e) {
20
ctx.AddError(e.what());
21
return
formats::json::Object{};
22
}
23
}
24
25
void
WriteProtoStruct(WriteContext&,
const
formats::json::Object& obj, ::google::protobuf::Struct& msg) {
26
protobuf::json::JsonToMessage(obj.GetValue(), msg, protobuf::json::ParseOptions{});
27
}
28
29
}
// namespace proto_structs::io
30
31
USERVER_NAMESPACE_END
proto-structs
src
proto-structs
io
userver
formats
json
object_conv.cpp
Generated on
for userver by
Doxygen
1.17.0