- Notifications
You must be signed in to change notification settings - Fork 18.4k
Open
Labels
NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
Description
This test I added to encoding/json
func TestUnmarshalCase(t *testing.T) { var v struct { Dist string `json:"dist"` } Unmarshal([]byte(`{"dist": "ok", "Dist": "KO"}`), &v) t.Logf("%+v", v) Unmarshal([]byte(`{"Dist": "ok", "dist": "KO"}`), &v) t.Logf("%+v", v) }
prints
x_test.go:13: {Dist:KO} x_test.go:16: {Dist:KO}
The comment says Unmarshal "prefers" exact matches, but if there are no words about what happens if multiple fields match.
It's clearly an odd case, but clarity would be nice. I expected the exact match to win always.
cristaloleg, quasilyte and FeldrinH
Metadata
Metadata
Assignees
Labels
NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.