JsonMappingException无法从START_ARRAY标记反序列化实例

时间:2018-02-21 18:45:16

标签: java api jackson fasterxml coinbase-api

我看了其他答案,但仍然无法确定我的问题。

我正在使用未完成的Coinbase API v2库并遇到一些问题。

该方法调用mapper.treeToValue(dataNode,classz);

其中dataNode是具有以下JSON的JSONNode

[
    {
        "id": "xxxx",
        "name": "LTC Wallet",
        "primary": false,
        "type": "wallet",
        "currency": {
            "code": "LTC",
            "name": "Litecoin",
            "color": "#B5B5B5",
            "exponent": 8,
            "type": "crypto",
            "address_regex": "^(L|M|3)[a-km-zA-HJ-NP-Z1-9]{25,34}$"
        },
        "balance": {
            "amount": "xxx",
            "currency": "LTC"
        },
        "created_at": "xxx",
        "updated_at": "xxx",
        "resource": "account",
        "resource_path": "/v2/accounts/xxx"
    },
    {
        "id": "xxx",
        "name": "ETH Wallet",
        "primary": false,
        "type": "wallet",
        "currency": {
            "code": "ETH",
            "name": "Ethereum",
            "color": "#6F7CBA",
            "exponent": 8,
            "type": "crypto",
            "address_regex": "^(?:0x)?[0-9a-fA-F]{40}$"
        },
        "balance": {
            "amount": "xxx",
            "currency": "ETH"
        },
        "created_at": "xxx",
        "updated_at": "xxx",
        "resource": "account",
        "resource_path": "/v2/accounts/xxx"
    }
]

classz属于Class类型,其中T是以下类;

public class ListAccount extends ListResponse<Account> {

ListResponse如下;

public abstract class ListResponse<T> {

    private Pagination pagination;
    private List<T> data;

    public Pagination getPagination() {
        return pagination;
    }
    public void setPagination(Pagination pagination) {
        this.pagination = pagination;
    }
    public List<T> getData() {
        return data;
    }
    public void setData(List<T> data) {
        this.data = data;
    }

}

我无法弄清楚这里有什么问题。提前感谢您的帮助。

0 个答案:

没有答案