| 357 | |
| 358 | template <typename OutputStream> |
| 359 | bool ProtoMessageToJsonStream(const google::protobuf::Message& message, |
| 360 | const Pb2JsonOptions& options, |
| 361 | OutputStream& os, std::string* error) { |
| 362 | PbToJsonConverter converter(options); |
| 363 | bool succ = false; |
| 364 | if (options.pretty_json) { |
| 365 | BUTIL_RAPIDJSON_NAMESPACE::PrettyWriter<OutputStream> writer(os); |
| 366 | succ = converter.Convert(message, writer); |
| 367 | } else { |
| 368 | BUTIL_RAPIDJSON_NAMESPACE::OptimizedWriter<OutputStream> writer(os); |
| 369 | succ = converter.Convert(message, writer); |
| 370 | } |
| 371 | if (!succ && error) { |
| 372 | error->clear(); |
| 373 | error->append(converter.ErrorText()); |
| 374 | } |
| 375 | return succ; |
| 376 | } |
| 377 | |
| 378 | bool ProtoMessageToJson(const google::protobuf::Message& message, |
| 379 | std::string* json, |
no test coverage detected