I have a json document with multiple objects. I have managed to print this out as a map but I want to be able to access elements within the values.
I can print the Map, but want to be able to print specific elements within the keys
for (Map.Entry<String,Object> entry : myMap.entrySet()) {
System.out.println("Key: "+entry.getKey() + " Value: "+entry.getValue());
}
This outputs the following:
Key: header1 Value: {id=123456, contents=[cat,dog,hamster]}
Key: header2 Value: {id=234567, contents=[spoon,knife,fork]}
I would like to be able to loop through and on each iteration assign id to a string and contents to a list
myMap.get("contents")but this doesn't work and I'm not really sure what sort of thing I should be looking up with regards to the syntax