I am trying to parse the following nested JSON object using RestTemplate's getForObject method:
"rates":{
"USD":1.075489,
"AUD":1.818178,
"CAD":1.530576,
"PLN":4.536389,
"MXN":25.720674
}
The number of currency rates varies depending on user input (it can be one or more).
How can I map such list of objects or a HashMap to a Java POJO class?
I tried with composition in the rates object:
public class Rates implements Serializable {
private List<ExternalApiQuoteCurrencyRate> list;
// getter and no-args constructor
}
public class ExternalApiQuoteCurrencyRate implements Serializable {
private String currency;
private BigDecimal rate;
// getters and no-args constructor
}
But the rates object gets deserialized as null.
Could somebody please help? Thanks a lot in advance!