I'm having an array look like this
[
{
object1:{ childObj1:[grandChild1,grandChild2], childObj1, childObj1}
},
{
object2:{ childObj1:[grandChild1,grandChild2], childObj1, childObj1}
},
{
object3:{ childObj1:[grandChild1,grandChild2], childObj1, childObj1}
},
]
Now i want to get rid of every nested item that have more than one item and keep only the first, like :
[
{
object1:{ childObj1:[grandChild1]}
},
{
object2:{ childObj2:[grandChild1]}
},
{
object3:{ childObj3:[grandChild1]}
},
]
Which is the most effective way to do this?