encoding/json: cannot use json:"-" to omit a shadowed field of an embedded type. #17016
Labels
Documentation
FrozenDueToAge
NeedsFix
The path to resolution is known, but the work has not been done.
Milestone
What version of Go are you using (
go version
)?Go 1.7
What operating system and processor architecture are you using (
go env
)?Locally I use:
But the playground also exhibits this behavior.
What did you do?
Embed a struct, shadow one of its fields, and add the
json:"-"
tag to omit the shadowed field.https://play.golang.org/p/AaXoSAfRTj
What did you expect to see?
I expected the json to not include a property for the shadowed field.
What did you see instead?
The shadowed field was included in the json.
After consideration, I believe the behavior is correct, because it allows the unmarshal case to work as one would expect, but the documentation doesn't lead one to expect the current behavior for marshalling.
The text was updated successfully, but these errors were encountered: