Say I have a Java map:
[
"Level 1.1":"Value1.1",
"Level 1.2":[
"Level2.1":"Value2.1"
"Level2.2":[
"Level3.1":"Value3.1"
]
]
]
Keys at all level are unique. Order of the keys can be changed at each level. It could have more then three levels.
I want to create a method called removeKey(). What it does is it will take an argument, or a list of arguments, and iterate through this map and remove that key at all levels.
So for example, calling removeKey("Level3.1") will remove that key on the third level down, and the map left will be:
[
"Level 1.1":"Value1.1",
"Level 1.2":[
"Level2.1":"Value2.1"
"Level2.2":[
]
]
]
Calling removeKey("Level3.1", "Level 2.2") will result in:
[
"Level 1.1":"Value1.1",
"Level 1.2":[
"Level2.1":"Value2.1"
]
]
Can you please help me with the method definition?
Thanks heaps.