-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
why marshal enum to json using string but received it with int . #1063
Comments
This seems strange, I think the default unmarshaler should support both of these, so it should parse the string correctly. Have you tried manually using the marshaler with your text to see if that works? m := &jsonpb.Unmarshaler{}
var v TestMessage
err := m.UnmarshalJSON(bytes.NewBufferString(`{"msg": "Ok"}`), &v)
... |
Nevermind, this is because of gogo protobuf's enum registration. You'll need to use the |
@johanbrandhorst thanks a lot. |
let me repeated how I fixed this:
go get github.com/gogo/gateway
that fixed. |
I still have a problem!
Bug reports:
Fill in the following sections with explanations of what's gone wrong.
Steps you follow to reproduce the error:
and this will marshal to json like this:
but when I send a request to server using :
this returns failed with message:
What did you expect to happen instead:
it unmarshal message succesed.
I tried
Ok
,ok
,OK
it all failed.but
{"msg":1}
succeed.this is my server options.
I can not add the option :
EnumsAsInts:true
because I would change many code.I am confused that why marshal to json using string but received it with int .
I generate my pb files using
github.com/gogo/protobuf
The text was updated successfully, but these errors were encountered: