how to unmarshal json object if object is returning as empty string instead of empty struct
问题 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 instead of data being {"key":{}} is {"key":""}} , it does not work even using omitempty field Example: https://play.golang.org/p/N1iuWBxuo1C type Store struct { Title string `json:"title,omitempty"` Item item `json:"item,omitempty"` } type item struct { Price float32 `json:"price,omitempty"` Kind string `json:"kind,omitempty"`