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: json.Marshal ignoring anonymous properties of struct #7076

gopherbot opened this issue Jan 8, 2014 · 2 comments


Copy link

by manishtpatel:

Above is the working sample. When using anonymous properties, marshal is ignoring them.

In given sample i expect output to be same for both structs.
Copy link

ceh commented Jan 8, 2014

Comment 1:

Working as intended? See
"Anonymous struct fields are usually marshaled as if their inner exported fields were
fields in the outer struct, subject to the usual Go visibility rules amended as
described in the next paragraph. An anonymous struct field with a name given in its JSON
tag is treated as having that name, rather than being anonymous."

Copy link

rsc commented Mar 3, 2014

Comment 2:

See comment #1

Status changed to WorkingAsIntended.

@golang golang locked and limited conversation to collaborators Jun 25, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet

No branches or pull requests

3 participants