You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
type Response2 struct {
Page int `json:"page"`
Fruits []Response2 `json:"fruits"`
}
func TestSomething1(t *testing.T) {
byt := []byte(`{"page":6,"fruits":[{"page":6,"fruits":[{"page":6,"fruits":""}]}]}`)
var dat Response2
if err := json.Unmarshal(byt, &dat); err != nil {
panic(err)
}
fmt.Println(dat)
}
for the above code, error message return by library is
json: cannot unmarshal string into Go struct field Response2.fruits of type []dtos.Response2
but better message could have been
json: cannot unmarshal string into Go struct field Response2.fruits[0].fruits[0].fruits of type []dtos.Response2
The text was updated successfully, but these errors were encountered:
smasher164
changed the title
No proper Error Message for Nested encoding
encoding/json: error message for nested encoding is not specific enough
Sep 16, 2019
go version go1.12.6
for the above code, error message return by library is
but better message could have been
The text was updated successfully, but these errors were encountered: