func (r *Report) UnmarshalJSON(b []byte) error {
	type report struct {
		IP         string     `json:"ip"`
		Categories []Category `json:"category"`
		Country    *string    `json:"country"`
		ISOCode    *string    `json:"isoCode"`
		Created    string     `json:"created"`
		Comment    string
	}
	var rep report
	err := json.Unmarshal(b, &rep)
	if err != nil {
		return err
	}

	r.IP = rep.IP
	r.Categories = rep.Categories
	r.Comment = rep.Comment

	if rep.Country != nil {
		r.Country = *rep.Country
	}
	if rep.ISOCode != nil {
		r.ISOCode = *rep.ISOCode
	}

	t, err := time.Parse(time.RFC1123Z, rep.Created)
	if err != nil {
		return err
	}
	r.Created = t

	return nil
}
// UnmarshalJSON implements the json.Unmarshaler inteface.
// A custom implementation is necessary because the standard Unmarshaler for
// time.Time expects RFC3339 format and the AbuseIPDB API uses RFC1123Z format.
UnmarshalJSON implements the json.Unmarshaler inteface.
A custom implementation is necessary because the standard Unmarshaler for
time.Time expects RFC3339 format and the AbuseIPDB API uses RFC1123Z format.
// UnmarshalJSON implements the json . Unmarshaler inteface . // A custom implementation is necessary because the standard Unmarshaler for // time . Time expects RFC3339 format and the AbuseIPDB API uses RFC1123Z format .
func (r *Report) UnmarshalJSON(b []byte) error {
	type report struct {
		IP         string     `json:"ip"`
		Categories []Category `json:"category"`
		Country    *string    `json:"country"`
		ISOCode    *string    `json:"isoCode"`
		Created    string     `json:"created"`
		Comment    string
	}
	var rep report
	err := json.Unmarshal(b, &rep)
	if err != nil {
		return err
	}
	r.IP = rep.IP
	r.Categories = rep.Categories
	r.Comment = rep.Comment
	if rep.Country != nil {
		r.Country = *rep.Country
	}
	if rep.ISOCode != nil {
		r.ISOCode = *rep.ISOCode
	}
	t, err := time.Parse(time.RFC1123Z, rep.Created)
	if err != nil {
		return err
	}
	r.Created = t
	return nil
}
func ( r * Report ) UnmarshalJSON ( b [ ] byte ) error { type report struct { IP string `json:"ip"` Categories [ ] Category `json:"category"` Country * string `json:"country"` ISOCode * string `json:"isoCode"` Created string `json:"created"` Comment string } var rep report err := json . Unmarshal ( b , & rep ) if err != nil { return err } r . IP = rep . IP r . Categories = rep . Categories r . Comment = rep . Comment if rep . Country != nil { r . Country = * rep . Country } if rep . ISOCode != nil { r . ISOCode = * rep . ISOCode } t , err := time . Parse ( time . RFC1123Z , rep . Created ) if err != nil { return err } r . Created = t return nil }
UnmarshalJSON implements the json.Unmarshaler inteface.
UnmarshalJSON implements the json . Unmarshaler inteface .