I want to map below Json data to java object of List<Map<String, String>> type.
Sample Json:
{
{
a:b,
c:d
},
{
e:f,
g:h,
i:j
},
{
h:k
}
}
Here a:b represents key-value pair. So a:b and c:d will be mapped to first map of the list and so on.
one way to do this is by building JSON tree and access each node and store the pair into the map.
Is there a better way to do this (cleaner approach)?
List<Map<String, String>>, it's more of aMap<String, Object>, whereObjectcan be aList<Map<String, Object>>or aList<Object>(and those nestedObjects can be the same two things as well). As for parsing it, I would personally use a json library but it's basically down to a state machine at that point (on the input symbols)