You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In continue to issue #212, I'm opening a new issue cause they're not necessarily related to each other.
I have changed my gRPC gateway server to use gogo/protobuf's jsonpb.Marshaler instead the one from golang/protobuf. I'm having another issue now; since the change, all JSON messages are marshaled by the jsonpb.Marshaler, but it uses the json field from the protobuf tag instead of the json tag (even if I'm using [(gogoproto.jsontag) = "..."]; which just overrides the json tag if I understood correctly).
Let's say I have the following message in my .proto file:
I've found the answer, but perhaps we should keep this issue as closed for documentation purposes.
If no WithMarshalerOption is provided to the grpc-gateway's NewServeMux function, it uses a default marshaler which is the jsopb.Marshaler from golang/protobuf, and it instantiates it like this:
defaultMarshaler=&JSONPb{OrigName: true}
So, the solution was just to set OrigName to true as well.
In continue to issue #212, I'm opening a new issue cause they're not necessarily related to each other.
I have changed my gRPC gateway server to use
gogo/protobuf
'sjsonpb.Marshaler
instead the one fromgolang/protobuf
. I'm having another issue now; since the change, all JSON messages are marshaled by thejsonpb.Marshaler
, but it uses thejson
field from theprotobuf
tag instead of thejson
tag (even if I'm using[(gogoproto.jsontag) = "..."]
; which just overrides thejson
tag if I understood correctly).Let's say I have the following message in my
.proto
file:In the
.pb.go
this translated to:So, the JSON looks like:
While (at least for my understanding) the expected result is (like it worked before):
What am I missing?
Any help will be much appreciated!
The text was updated successfully, but these errors were encountered: