1
This commit is contained in:
parent
28b0153ca7
commit
3390412e54
@ -9,7 +9,10 @@
|
||||
#include <a8/mutable_xobject.h>
|
||||
|
||||
#include <google/protobuf/message.h>
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
#if GOOGLE_PROTOBUF_VERSION > 2005000
|
||||
#include <google/protobuf/util/json_util.h>
|
||||
#endif
|
||||
|
||||
#include "framework/cpp/utils.h"
|
||||
|
||||
@ -535,11 +538,15 @@ namespace f8
|
||||
std::string PbToJson(google::protobuf::Message* pbmsg)
|
||||
{
|
||||
std::string json;
|
||||
#if GOOGLE_PROTOBUF_VERSION > 2005000
|
||||
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();
|
||||
#else
|
||||
json = "{}";
|
||||
#endif
|
||||
return json;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user