Reputation: 1
I need to map a JSON object but the problem is that it has an inner custom list. How could use RestTemplate in this case?
I am trying to use ResponseEntity and ParameterizedTypeReference but I have not found the solution yet.
{
"results":{
"ALL":{
"currencyName":"Albanian Lek",
"currencySymbol":"Lek",
"id":"ALL"
},
"XCD":{
"currencyName":"East Caribbean Dollar",
"currencySymbol":"$",
"id":"XCD"
},
"EUR":{
"currencyName":"Euro",
"currencySymbol":"€",
"id":"EUR"
},
"BBD":{
"currencyName":"Barbadian Dollar",
"currencySymbol":"$",
"id":"BBD"
},
"BTN":{
"currencyName":"Bhutanese Ngultrum",
"id":"BTN"
},
"BND":{
"currencyName":"Brunei Dollar",
"currencySymbol":"$",
"id":"BND"
},
"XAF":{
"currencyName":"Central African CFA Franc",
"id":"XAF"
},
"CUP":{
"currencyName":"Cuban Peso",
"currencySymbol":"$",
"id":"CUP"
},
"USD":{
"currencyName":"United States Dollar",
"currencySymbol":"$",
"id":"USD"
}
}
}
Upvotes: 0
Views: 38
Reputation: 199
// you can create a custom class like below and try to map it
class NodeWrapper{
private Map<String, NodeData> results;
}
class NodeData{
private String currencyName;
private String currencySymbol;
private id;
}
// also allow nulls using object mapper annotations
Upvotes: 0