Hello everyone,

In our setup we use Google Cloud Enpoints and the esp container in our 
cloud environments, but grpc-gateway for our local development. We see a 
difference in behaviour when transcoding protobuf to JSON, namely in how 
protobufs default values are transcoded. This has lead to some subtle bugs, 
whuch is why I am writing to you.

At the core of this issue are two different implementations of JSON 
transcoding:

   1. one in C++ in protobuf/src/google/protobuf/util/json_util.h 
   
<https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/util/json_util.h#L75>
 with 
   an option "always_print_primitive_fields" in the struct JsonPrintOptions
   2. another in Go in  protobuf-go/encoding/protojson/encode.go 
   
<https://github.com/protocolbuffers/protobuf-go/blob/master/encoding/protojson/encode.go#L83>
 with 
   an option "EmitUnpopulated" in the struct MarshalOptions
   
The esp(-v2) container uses the first one, while grpc-gateway will* use the 
second.

The obvious question now is: *Do you plan on synchronizing both 
implementations, or provide extra options so they can be configured to work 
identically?*

For extra context: I already opened an issue at the esp-v2 GitHub repo 
<https://github.com/GoogleCloudPlatform/esp-v2/issues/150>

Kind regards,
Vital D'haveloose
UZ Leuven, Belgium

(*) grpc-gateway currently uses the old 1.3.3 
<https://github.com/golang/protobuf/blob/b5de78c91d0d09482d65f0a96927631cd343d7bb/jsonpb/encode.go#L39>
 
implementation of protobuf for Go, where the EmitUnpopulated option is 
called "EmitDefaults", but they are planning 
<https://github.com/grpc-ecosystem/grpc-gateway/issues/1147> on upgrading.


PS: this is my first message here, if it doesn't confirm to the way things 
are done here please let me know. Apologies in advance :-)

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/70428d0f-d943-45d3-86d8-833de7df7217n%40googlegroups.com.

Reply via email to