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

Closed
gopherbot opened this issue Jan 29, 2014 · 1 comment

Comments

Projects
None yet
2 participants
@gopherbot
Copy link

commented Jan 29, 2014

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 http://play.golang.org/p/-ZtaIGe7QJ 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
@rsc

This comment has been minimized.

Copy link
Contributor

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
unmarshal? http://play.golang.org/p/orp7cvQplU

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.
You can’t perform that action at this time.