I have a nested Json that I need to remove some objects in array with a filter, this in a dynamic way, this Json structure is not the same all time, for example:
{
"A": "HI",
"B": 1,
"C": [
{
"TIME": "TODAY",
"LOCATION": "USA",
"BALANCE": 100,
"STATE": "TX",
"NAME": "JHON"
},
{
"TIME": "YESTERDAY",
"LOCATION": "USA",
"BALANCE": 100,
"STATE": "TX",
"NAME": "MICHAEL"
},
{
"TIME": "YESTERDAY",
"LOCATION": "USA",
"BALANCE": 100,
"STATE": "TX",
"NAME": "REBECCA"
}
]
}
And now, from this kind of nested Json I want to remove the Object that contains key "NAME" with VALUE "Michael", and the result have to be this one:
{
"A": "HI",
"B": 1,
"C": [
{
"TIME": "TODAY",
"LOCATION": "USA",
"BALANCE": 100,
"STATE": "TX",
"NAME": "JHON"
},
{
"TIME": "YESTERDAY",
"LOCATION": "USA",
"BALANCE": 100,
"STATE": "TX",
"NAME": "REBECCA"
}
]
}
This JSON change every time depending on reponse from an API, just I have to match KEY - VALUE to remove the Object that I need filter without modify the Json structure, in this case I need to recive KEY = "NAME" and VALUE = "Michael" to filter this object.
In this case "C" is a variable key and I could have more keys with arrays in the same json that need to be filtered, I need a dynamic way to filter in array of objects based just in key-value
Could you help me find a way to perform this functionality?