Я пытаюсь разобрать простую строку Джейсона:
type City struct {
ID int `jsonapi:"primary,cities"`
CountryCode string `jsonapi:"attr,countryCode"`
Name string `jsonapi:"attr,name"`
}
func TestGetCityByID(t *testing.T) {
const mockCity = `{
"data":{
"type":"cities",
"id":"123",
"attributes":{
"name":"Berlin",
"countryCode":"DE"
}
}
}`
city := new(City)
err := jsonapi.UnmarshalPayload(strings.NewReader(mockCity), &city)
log.Info(err) //data is not a jsonapi representation of '**neustargeodata.City'
log.Info(city)
}
Я не вижу никакой разницы между строкой json и результатом маршалинга городского объекта, есть ли какие-либо идеи о том, что я делаю неправильно? Заранее большое спасибо!