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:
- one in C++ in protobuf/src/google/protobuf/util/json_util.h with an option "always_print_primitive_fields" in the struct JsonPrintOptions
- another in Go in
protobuf-go/encoding/protojson/encode.go 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 repoKind regards,
Vital D'haveloose
UZ Leuven, Belgium
(*) grpc-gateway currently uses the
old 1.3.3 implementation of protobuf for Go, where the EmitUnpopulated option is called "EmitDefaults", but they are
planning 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 :-)