-
Notifications
You must be signed in to change notification settings - Fork 18.7k
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
type GoStruct1 struct {
AlphaField GoStruct2 `json:"alpha_field"`
}
type GoStruct2 struct {
BravoField []GoStruct3 `json:"bravo_field"`
}
type GoStruct3 struct {
StringField string `json:"string_field"`
}
func main() {
fmt.Println(json.Unmarshal([]byte(`{"alpha_field":{"bravo_field":[{"string_field": 3.14159}]}}`), new(GoStruct1)))
}On Go1.15, this prints:
json: cannot unmarshal number into Go struct field GoStruct3.alpha_field.bravo_field.string_field of type string
Notice that it combines two different namespaces where it is:
{{GoTypeName}}.{{JSONPath}}
and that the message says that it is a "Go struct field" when it isn't.
Also, it uses GoStruct3, when it makes little sense.
At minimum, it should at least used GoStruct1.
\cc @mvdan
fl0cke, sergolius, firelizzard18 and smyrman
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.