From 3390412e54cef4964d65f6f686b56b7fc7e0ea7b Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 31 Mar 2022 14:05:16 +0800 Subject: [PATCH] 1 --- cpp/utils.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cpp/utils.cc b/cpp/utils.cc index 86ea54c..e2702af 100644 --- a/cpp/utils.cc +++ b/cpp/utils.cc @@ -9,7 +9,10 @@ #include #include +#include +#if GOOGLE_PROTOBUF_VERSION > 2005000 #include +#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; }