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: Struct behind interface embedding behaves differently to struct-only embedding #7230

gopherbot opened this issue Jan 29, 2014 · 1 comment


Copy link

by pronox:

Marshaling flattens embedded struct fields just fine but fails with struct fields
abstracted by interface types. In essence:

    struct{ someStruct }{someStruct{}} // properly flattened

    type Any interface{}
    struct{ Any }{someStruct{}} // not flattened: "Any":{ ... }

See for an example.

I think if the underlying type of the embedded interface is a struct the output should
be flattened.

go version devel +9c65fe4ce5a2 Wed Jan 29 09:51:31 2014 +0900 linux/amd64
Copy link

rsc commented Mar 3, 2014

Comment 1:

Embedded interfaces and embedded structs are just different. Here is a version of your
program demonstrating the difference. If we "flatten", then how do we know how to

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

2 participants