I'm using wrappers.proto in my own API that sits behind
Google's Extensible Service Proxy. The proxy trans-codes JSON
<-> ProtoBuf. Code for trans-coding is
Status ProtoToJson(const Message& message, std::string* result, int options) {
::google::protobuf::util::JsonPrintOptions json_options;
if (options & JsonOptions::PRETTY_PRINT) {
json_options.add_whitespace = true;
}
if (options & JsonOptions::OUTPUT_DEFAULTS) {
json_options.always_print_primitive_fields = true;
}
// TODO: Skip going to bytes and use ProtoObjectSource directly.
::google::protobuf::util::Status status = ::google::protobuf::util::BinaryToJsonString( GetTypeResolver(), GetTypeUrl(message),
message.SerializeAsString(),
result, json_options);
return Status::FromProto(status);
}
Note the call to message.SerializeAsString()
I've noticed my web client receives any wrapper messages, without their wrapper. For example, my server constructs a message
message NumberOptions {
google.protobuf.Int32Value minimum = 1;
google.protobuf.Int32Value maximum = 2;
}
with the following values:
minimum {
value: 1
}
maximum {
value: 100
}
However, after my message passes through the ESP (and is serislised to JSON), my client receives:
Does SerializeAsString automatically unpack any wrapper messages? If so, can I also send JSON:
..and expect wrappers to be created (if the message is defined to use wrappers), i.e.
message NumberOptions {
google.protobuf.Int32Value minimum = 1;
google.protobuf.Int32Value maximum = 2;
}