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

Closed
gopherbot opened this issue Jan 8, 2014 · 2 comments
Closed

encoding/json: json.Marshal ignoring anonymous properties of struct #7076

gopherbot opened this issue Jan 8, 2014 · 2 comments

Comments

@gopherbot
Copy link

@gopherbot gopherbot commented Jan 8, 2014

by manishtpatel:

http://play.golang.org/p/ZG7QaannqG

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.
@ceh

This comment has been minimized.

Copy link
Contributor

@ceh ceh commented Jan 8, 2014

Comment 1:

Working as intended? See http://golang.org/pkg/encoding/json/#Marshal
"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."
@rsc

This comment has been minimized.

Copy link
Contributor

@rsc 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.
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.