goccy / go-json

Fast JSON encoder/decoder compatible with encoding/json for Go
MIT License
3.11k stars 148 forks source link

Decoder doesn't display a type mismatch #518

Open pdebakker-auguria opened 3 months ago

pdebakker-auguria commented 3 months ago

We had a situation like

type WLB struct {
    Accessmask          []string `json:"accesmask"`
    ...

But sometimes in our dataset, this field was actually just a string. The error that the json.Decoder.decode() was json: slice unexpected end of JSON input.

Shouldn't the error be that the value doesn't have the expected type instead?