3
我使用Spring RestTemplate
将GET request
发送给第三方服务。它返回巨大的JSON
,代表list of some entities
。但是每个实体都非常庞大,包含大量不必要的数据。我只需要从每个实体获得三个字段。我如何建立我的模型来实现它?例如,如果我们有这样的JSON
:使用RestTemplate部分检索JSON
{
"entity1": "foo",
"entity2": "bar",
"entity3": "...",
"entity4": {
"aaa": "...",
"bbb": "...",
"ccc": 5
},
"entity5": [
"...",
"..."
]
}, {
"entity1": "foo",
"entity2": "bar",
"entity3": "...",
"entity4": {
"aaa": "...",
"bbb": "...",
"ccc": 5
},
"entity5": [
"...",
"..."
]
}
而且我有一个类:
public class SomeModel implements Serializable {
private static final long serialVersionUID = 1L;
private Long entity1;
private String entity2;
}
我怎么能这个JSON转换为该类的实例的阵列?
非常感谢,它帮助! :) – Alesto