json 字符串未被 jsonapi.UnmarshalPayload 解组

json string doesnt get unmarshalled with jsonapi.UnmarshalPayload

我正在尝试解组一个简单的 jason 字符串:

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 字符串和编组城市对象的结果有什么区别,知道我做错了什么吗?非常感谢!

好的,我只需要将 &city 更改为 city!