1
This commit is contained in:
parent
180f9e3f5c
commit
28b0153ca7
12
cpp/utils.cc
12
cpp/utils.cc
@ -9,6 +9,7 @@
|
||||
#include <a8/mutable_xobject.h>
|
||||
|
||||
#include <google/protobuf/message.h>
|
||||
#include <google/protobuf/util/json_util.h>
|
||||
|
||||
#include "framework/cpp/utils.h"
|
||||
|
||||
@ -531,4 +532,15 @@ namespace f8
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string PbToJson(google::protobuf::Message* pbmsg)
|
||||
{
|
||||
std::string json;
|
||||
google::protobuf::util::JsonPrintOptions options;
|
||||
options.add_whitespace = true;
|
||||
options.always_print_primitive_fields = true;
|
||||
options.preserve_proto_field_names = true;
|
||||
MessageToJsonString(*pbmsg, &json, options).ok();
|
||||
return json;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -119,4 +119,5 @@ namespace f8
|
||||
bool IsTestEnv();
|
||||
bool IsValidNormalConfig(a8::XObject& conf, std::vector<std::string> fields);
|
||||
|
||||
std::string PbToJson(google::protobuf::Message* pbmsg);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user