Pranay Kumar :
I have a JSON of the format
[{
"id" : "a01",
"name" : "random1",
"val" : "random2"
},
{
"id" : "a03",
"name" : "random3",
"val" : "random4"
}]
I need to map it to a List
holding various Map
objects. How do I achieve it?
Even if I am able to convert this JSON to a List
of String
of the form
{
"id" : "a01",
"name" : "random1",
"val" : "random2"
}
then I have a method to convert each individual String
to a Map
.
Manos Nikolaidis :
You will need to pass a TypeReference
to readValue
with the desired result type:
ObjectMapper mapper = new ObjectMapper();
List<Map<String, Object>> data = mapper.readValue(json, new TypeReference<List<Map<String, Object>>>(){});
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=439970&siteId=1