var v []int
fmt.Println(json.Unmarshal([]byte(`["foo"]`), &v))
v1 error: "json: cannot unmarshal string into Go value of type int" v1-wrapping-v2 error: "json: cannot unmarshal string into Go struct field .0 of type int"
But there's no struct involved.
The plain v2 error is better, probably fine: json: cannot unmarshal JSON string into Go int within "/0"
Comment From: neild
/cc @dsnet
Comment From: gabyhelp
Related Issues
- encoding/json/v2: UnmarshalTypeError text changes #74713 (closed)
- encoding/json: output not always valid input #8962 (closed)
- encoding/json: nested unmarshaling mangles errors #68750 (closed)
- encoding/json: Unmarshal. Expected type string -> found int. #26928 (closed)
- encoding/json: wrong type name used in UnmarshalTypeError #68941 (closed)
- encoding/json: error message for nested encoding is not specific enough #34327 (closed)
- json.Unmarshal bug #13260 (closed)
- encoding/json: UnmarshalTypeError.Error message seems insensible #43126
- encoding/json: cannot unmarshal e-notation number into integer type #8460 (closed)
- encoding/json: unmarshal regression for extra data error under goexperiment.jsonv2 #74614 (closed)
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)