如何仅反序列化items数组?
{
"code": 200,
"bookmarks": {
"count": 2,
"items": [
{
"status": "I",
"id": "1",
"percent": 9,
"timestamp": 1462826317475
},
{
"status": "I",
"id": "2",
"percent": 10,
"timestamp": 1462909994981
}
],
"links": []
}
}
我知道一个数组我可以这样做:
List<MyClass> myObjects = mapper.readValue(jsonInput, new TypeReference<List<MyClass>>(){});
我是否可以仅指定反序列化项目?
答案 0 :(得分:1)
使用ObjectReader
s at(JsonPointer)
方法指定要绑定的子树。类似的东西:
Item[] items = mapper.readerFor(Item[].class).at("/bookmarks/items").readValue();