I am trying to use Jackson in Java to parse a string of Json Array in the format of
"[{"key1":"value1"},{"key2":{"keyChild1":"valueChild1","keyChild2","valueChild2"}}]"
However, the JSON object inside the string of array could be any arbitrary valid JSON, which means I cannot map them to any predefined POJO as suggested in Parsing JSON in Java without knowing JSON format
The goal is to convert this string of JSON array to a List<someObject>
that can represent each of the JSON inside the array, and this someObject
will allow me to add/remove any key/value pairs in that JSON.
I have tried to use
final ObjectMapper objectMapper = new ObjectMapper();
List<JsonNode> jsonNodes = objectMapper.readValue(jsonArraytring, new TypeReference<List<JsonNode>>() {});
and it seems like the List to be empty. I really got stuck here.
Any help would be appreciated.