|
|
|
@ -46,7 +46,6 @@ |
|
|
|
|
#include "google/protobuf/dynamic_message.h" |
|
|
|
|
#include "google/protobuf/message.h" |
|
|
|
|
#include "absl/log/absl_check.h" |
|
|
|
|
#include "absl/log/absl_log.h" |
|
|
|
|
#include "absl/status/status.h" |
|
|
|
|
#include "absl/strings/ascii.h" |
|
|
|
|
#include "absl/strings/escaping.h" |
|
|
|
@ -855,20 +854,16 @@ absl::Status WriteMessage(JsonWriter& writer, const Msg<Traits>& msg, |
|
|
|
|
|
|
|
|
|
absl::Status MessageToJsonString(const Message& message, std::string* output, |
|
|
|
|
json_internal::WriterOptions options) { |
|
|
|
|
if (PROTOBUF_DEBUG) { |
|
|
|
|
ABSL_DLOG(INFO) << "json2/input: " << message.DebugString(); |
|
|
|
|
} |
|
|
|
|
PROTOBUF_DLOG(INFO) << "json2/input: " << message.DebugString(); |
|
|
|
|
io::StringOutputStream out(output); |
|
|
|
|
JsonWriter writer(&out, options); |
|
|
|
|
absl::Status s = WriteMessage<UnparseProto2Descriptor>( |
|
|
|
|
writer, message, *message.GetDescriptor(), /*is_top_level=*/true); |
|
|
|
|
if (PROTOBUF_DEBUG) ABSL_DLOG(INFO) << "json2/status: " << s; |
|
|
|
|
PROTOBUF_DLOG(INFO) << "json2/status: " << s; |
|
|
|
|
RETURN_IF_ERROR(s); |
|
|
|
|
|
|
|
|
|
writer.NewLine(); |
|
|
|
|
if (PROTOBUF_DEBUG) { |
|
|
|
|
ABSL_DLOG(INFO) << "json2/output: " << absl::CHexEscape(*output); |
|
|
|
|
} |
|
|
|
|
PROTOBUF_DLOG(INFO) << "json2/output: " << absl::CHexEscape(*output); |
|
|
|
|
return absl::OkStatus(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -901,9 +896,7 @@ absl::Status BinaryToJsonStream(google::protobuf::util::TypeResolver* resolver, |
|
|
|
|
tee_output.emplace(&out); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (PROTOBUF_DEBUG) { |
|
|
|
|
ABSL_DLOG(INFO) << "json2/input: " << absl::BytesToHexString(copy); |
|
|
|
|
} |
|
|
|
|
PROTOBUF_DLOG(INFO) << "json2/input: " << absl::BytesToHexString(copy); |
|
|
|
|
|
|
|
|
|
ResolverPool pool(resolver); |
|
|
|
|
auto desc = pool.FindMessage(type_url); |
|
|
|
@ -919,7 +912,7 @@ absl::Status BinaryToJsonStream(google::protobuf::util::TypeResolver* resolver, |
|
|
|
|
absl::Status s = WriteMessage<UnparseProto3Type>( |
|
|
|
|
writer, *msg, UnparseProto3Type::GetDesc(*msg), |
|
|
|
|
/*is_top_level=*/true); |
|
|
|
|
if (PROTOBUF_DEBUG) ABSL_DLOG(INFO) << "json2/status: " << s; |
|
|
|
|
PROTOBUF_DLOG(INFO) << "json2/status: " << s; |
|
|
|
|
RETURN_IF_ERROR(s); |
|
|
|
|
|
|
|
|
|
if (PROTOBUF_DEBUG) { |
|
|
|
@ -928,9 +921,7 @@ absl::Status BinaryToJsonStream(google::protobuf::util::TypeResolver* resolver, |
|
|
|
|
.Append(out.data(), out.size()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (PROTOBUF_DEBUG) { |
|
|
|
|
ABSL_DLOG(INFO) << "json2/output: " << absl::CHexEscape(out); |
|
|
|
|
} |
|
|
|
|
PROTOBUF_DLOG(INFO) << "json2/output: " << absl::CHexEscape(out); |
|
|
|
|
|
|
|
|
|
writer.NewLine(); |
|
|
|
|
return absl::OkStatus(); |
|
|
|
|