I'm using Spring RestTemplate
to send GET request
to the third-party service. It returns huge JSON
which represents a list of some entities
. But every entity is really big and contains tons of unnecessary data. I need to get only three fields from every entity. How can I build my model to achieve it? For example if we have this JSON
:
{
"entity1": "foo",
"entity2": "bar",
"entity3": "...",
"entity4": {
"aaa": "...",
"bbb": "...",
"ccc": 5
},
"entity5": [
"...",
"..."
]
}, {
"entity1": "foo",
"entity2": "bar",
"entity3": "...",
"entity4": {
"aaa": "...",
"bbb": "...",
"ccc": 5
},
"entity5": [
"...",
"..."
]
}
And I have a class:
public class SomeModel implements Serializable {
private static final long serialVersionUID = 1L;
private Long entity1;
private String entity2;
}
How can I convert this JSON to the array of instances of this class?