-
Notifications
You must be signed in to change notification settings - Fork 18k
encoding/json: json.RawMessage does not works correctly #35992
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
Comments
This comment has been minimized.
This comment has been minimized.
Hey! Thank you for answer. InstanceId is sample field. I have over 100 different message types and want to reflect json to different golang structs (I use switch evnvelope.Type ... json.Unmarshal(envelope.Json, &concreteType)...) I don't want And this is a bug with json.RawMessage |
EDIT: yeah misread. Re-opening. |
Same problem with marshaling. I marshal {Type, some_message} data and get some_message only without __type )) |
Hi @gromas, Referring to your first example:
What exactly do you expect to appear in the |
@gromas Your second example you are embedding a |
Thanks @seankhliao. I'm going to close this issue, as it is not clear that this is a bug. @gromas, please see one of the resources on https://golang.org/wiki/Questions for further help using the |
I want to unmarshal JSON to different struct types and I write:
I get empty envelope.Json but must be an byte array (json.RawMessage).
repro:
https://play.golang.org/p/m6wd44R35FZ
The text was updated successfully, but these errors were encountered: