I\'m receiving some data as JSON, but if a object is empty, it does not return a empty struct but a empty string instead, and when unmarshaling, it returns an error.
So
You can have your item type implement the json.Unmarshaler interface.
item
func (i *item) UnmarshalJSON(data []byte) error { if string(data) == `""` { return nil } type tmp item return json.Unmarshal(data, (*tmp)(i)) }
https://play.golang.org/p/1TrD57XULo9