Skip to content
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

encoding/json: behaves incorrectly on nested structs with json.RawMessage #10551

Closed
zombor opened this issue Apr 22, 2015 · 5 comments
Closed

Comments

@zombor
Copy link

zombor commented Apr 22, 2015

Example here: https://play.golang.org/p/lozTmQr8pR

I'd expect all three outputs to be sane json. There should be no errors here.

@minux
Copy link
Member

minux commented Apr 22, 2015 via email

@zombor
Copy link
Author

zombor commented Apr 22, 2015

Can you explain why? I'd expect similar output to []byte: https://play.golang.org/p/krJb2ZhRVD

@minux
Copy link
Member

minux commented Apr 22, 2015 via email

@zombor
Copy link
Author

zombor commented Apr 22, 2015

Then why does the last example run fine? There should be some consistency, at the very least.

json.Marshal(json.RawMessage(nil))

Outputs "null"

@minux
Copy link
Member

minux commented Apr 23, 2015 via email

@minux minux closed this as completed Apr 24, 2015
@minux minux changed the title encoding/json behaves incorrectly on nested structs encoding/json: behaves incorrectly on nested structs with json.RawMessage Apr 24, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants