I've used restTemplate to get the details from a third party API.
Where, below code give me a response in string (using response.getBody())
ResponseEntity<String> response = restTemplate.exchange(uri, HttpMethod.GET, entity, String.class);
Example of JSON
{"Entries":[{"EntryId":"1","Field1":"1","Field2":"2"},{"EntryId":"2","Field1":"3","Field2":"4"}]}
I've also created a class called Entries,
@JsonIgnoreProperties(ignoreUnknown=true)
public class Entries {
@JsonProperty("EntryId")
private String entryId;
@JsonProperty("Field1")
private String field1;
@JsonProperty("Field2")
private String field2;
//getter and setters
Is there any way to map JSON Array with Entires class using RestTemplate?
restTemplate.getForEntity(resourceUrl, Entity.class);restTemplate.exchange(). I've just found a solution and which is posted below.