I have a HashMap<String, Object> that looks like this when I call .toString() on it:
{somekey=false, anotherKey=someString, thirdKey={nestedKey=hello, nestedKey2=world,etc=etcetcetc}}
At a certain point in my script, I would like to iterate over the “thirdKey” set as its own map. Is there a common convention used to isolate a “nested” HashMap and use it as its own one-dimensional map?
Here’s my code for recursively extracting all values from the map (and the maps within these map).
As Vikdor already said, I don’t think there is a real convention for this.
Edit:
You could, of course, also write the keys and values into a new Map (“flattening” it). I just added the values to a List, because this way you don’t run into problems when one of the nested maps uses an already present key.