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

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

zombor opened this issue Apr 22, 2015 · 5 comments

Comments

@zombor
Copy link

@zombor 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

This comment has been minimized.

Copy link
Member

@minux minux commented Apr 22, 2015

@zombor

This comment has been minimized.

Copy link
Author

@zombor zombor commented Apr 22, 2015

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

@minux

This comment has been minimized.

Copy link
Member

@minux minux commented Apr 22, 2015

@zombor

This comment has been minimized.

Copy link
Author

@zombor 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

This comment has been minimized.

Copy link
Member

@minux minux commented Apr 23, 2015

@minux minux closed this 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
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.