我的 Android 应用程序中有以下 JSON,并且我正在使用 Springs for android RestTemplate
。是否可以以某种方式从此 json 中仅获取内部列表?目前我必须创建一个包装对象,然后我可以获取 List<Cast> casts;
从它 - 这有点不方便。
{
"id": 550,
"cast": [
{
"cast_id": 4,
"character": "The Narrator",
"credit_id": "52fe4250c3a36847f80149f3",
"id": 819,
"name": "Edward Norton",
"order": 0,
"profile_path": "/iUiePUAQKN4GY6jorH9m23cbVli.jpg"
}
]
}
最佳答案
我知道解决这个问题的两种解决方案:
- 您所做的:使用类包装列表
- 编写你自己的 JSON 反序列化器,看看这里 http://wiki.fasterxml.com/JacksonHowToCustomDeserializers
但我认为最终的解决方案在这篇文章中: Spring/json: Convert a typed collection like List<MyPojo>
关于java - Spring RestTemplate jackson 获取特定字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29722054/