【发布时间】:2016-08-11 13:27:31
【问题描述】:
我正在使用Spring RestTemplate 将GET request 发送到第三方服务。它返回巨大的JSON,它代表list of some entities。但是每个实体都非常大,并且包含大量不必要的数据。我只需要从每个实体中获取三个字段。我怎样才能建立我的模型来实现它?例如,如果我们有这个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 转换为此类的实例数组?
【问题讨论】:
标签: json spring get resttemplate spring-web