I need to remove the complete JSON object by its key name, I have random JSON every time, I need to find a particular element and remove it. for example, I have the following JSON:
{
"abc":{
"remove_me": "123456"
}
}
but may next time I may have the following
{
"abc": {
"xyz": {
"test": "test"
}
},
"abc1": {
"xyz1": {
"remove_me": "232233",
"test": "dfefd",
}
}
}
every time I have a different JSON format, even in more complex formats. but the key I have to remove the element is remove_me
I am doing it in Java, please help!
Map<String, Object>, then traverse map similar to deep first search logic (checking whether map's value is list, map or any other object, and invoking method recursively), and if key during traversing isremove_me, you need to remove it.