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