How to json unmarshalling with custom attribute type in Go
问题 In my project, I've defined structures so that get data from JSON. I tried to use json.Unmarshal() function. But it did not work for custom type attribute. There was a structure like this: type TestModel struct { ID NullInt `json:"id"` Name string `json:"name"` } In there, NullInt type was defined with implementations of MarshalJSON() and UnmarshalJSON() functions: // NullInt ... type NullInt struct { Int int Valid bool } // MarshalJSON ... func (ni NullInt) MarshalJSON() ([]byte, error) { if