First define an object to hold the entity coming back in the array.. e.g.
@JsonIgnoreProperties(ignoreUnknown = true)
public class Rate {
private String name;
private String code;
private Double rate;
// add getters and setters
}
Then you can consume the service and get a strongly typed list via:
ResponseEntity<List<Rate>> rateResponse =
restTemplate.exchange("https://bitpay.com/api/rates",
HttpMethod.GET, null, new ParameterizedTypeReference<List<Rate>>() {
});
List<Rate> rates = rateResponse.getBody();
The other solutions above will also work, but I like getting a strongly typed list back instead of an Object[].
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…