当前位置: 首页 > 知识库问答 >
问题:

Jackson JSon:无法反序列化START_OBJECT令牌外的java.lang.String实例

咸疏珂
2023-03-14

我尝试声明为String或List,但没有成功。知道吗?

{
"libs": {},
"items": [
    {
        "id": "001",
        "cars": [
            "cd1042af-856d-4649-a170-032d15a4119b",
            "00ed61a4-3aab-4722-90c2-7f4cca4cbded",
            "8fa3aa8b-3f22-4413-a41d-e78de9051de2"
        ],
        "name": "James"


    },
    {

        "id": "002",
        "cars": [
            "cd1043af-856d-4649-a170-032d15a4119b",
            "00ed61a4-3aab-4722-90c2-7f4cca4cbded",
            "8fa3aa8b-3f22-4413-a41d-e78de9051de2"
        ],
        "name": "James"

    }]

}

public class Page<Car> {


    private List<String> libs;

    private List<Car>items;



    public List<Car> getItems() {
        return items;
    }

    public void setItems(List<Car> items) {
        this.items = items;
    }

    public List<String> getLibs() {
        return libs;
    }

    public void setLibs(List<String> libs) {
        this.libs = libs;
    }



}

共有1个答案

吴谦
2023-03-14

您将库声明为列表,但使用了Maps/Objects括号。

“libs”:[]

并且在每个列表元素的name属性末尾后都有额外的逗号。

 类似资料: