| 376 | } |
| 377 | |
| 378 | bool ProtoMessageToJson(const google::protobuf::Message& message, |
| 379 | std::string* json, |
| 380 | const Pb2JsonOptions& options, |
| 381 | std::string* error) { |
| 382 | // TODO(gejun): We could further wrap a std::string as a buffer to reduce |
| 383 | // a copying. |
| 384 | BUTIL_RAPIDJSON_NAMESPACE::StringBuffer buffer; |
| 385 | if (json2pb::ProtoMessageToJsonStream(message, options, buffer, error)) { |
| 386 | json->append(buffer.GetString(), buffer.GetSize()); |
| 387 | return true; |
| 388 | } |
| 389 | return false; |
| 390 | } |
| 391 | |
| 392 | bool ProtoMessageToJson(const google::protobuf::Message& message, |
| 393 | std::string* json, std::string* error) { |