I have an object as below:
var obj =
{
a :
{
"x": "abc",
"y": "def",
"z": "ghi"
},
b :
{
"p" : "jkl",
"q" : "mno",
"r" : "pqr"
},
...
...
}
I want the output as below:
var targetObject =
{
"a_x":"abc",
"a_y":"def",
"a_z":"ghi",
..
..
..
..
}
There can be n number of key as well as hierarchy. Can we have a function where the input is the object and the output gives me that targetObject?