02-03-2020 12:48 PM
Hello All,
I have a requirement to extract values of an object based on it’s key through a lookup.
For Example i have following json structure :
{
“A”:{
“B” : {“value” :“test”},
“C” : {“value” :“test”},
“D” : {“value” :“test”},
“E” : {“value” :“test”},
}
A,B,C,D,E all are objects.
i want to extract only B’s value when the key matches to B.
Regards,
Asheerbad
02-04-2020 01:23 PM
You can use bracket notation to do a lookup based on the value of an expression:
$A[$keyToLookup]
So, if $keyToLookup
contained “B”, the above expression would drill down into the “A” object and get the value of the property named “B” .