I want transform a Javascript object to a different form. Lets take an example.
may be I have an object like this,
[
{
"_id": 1,
"name": "abc",
"sub": [
"bbb",
"ccc"
]
},
{
"_id": 1,
"name": "abc1",
"sub": [
"bbb1"
]
},
{
"_id": 1,
"name": "abc"
}
]
and I want to transform that like below,
[
{
"_id": 1,
"name": "abc",
"sub": [
{
"sub": "bbb"
},
{
"sub": "ccc"
}
]
},
{
"_id": 1,
"name": "abc1",
"sub": [
{
"sub": "bbb1"
}
]
},
{
"_id": 1,
"name": "abc"
}
]
can anyone please help me to solve this. Thanks.