I have a tree object as below, I am trying to remove the items array property if it's empty. I am not sure on the best approach to do this?
I am thinking of looping through the key, check the property and then remove using delete myJSONObject[prop]... Any thoughts / ideas are welcome?
[{
text: "TreeRoot",
items: [{
text: "Subgroup1",
items: []
}, {
text: "Subgroup2",
items: []
}, {
text: "Subgroup3",
items: [],
items: [{
text: "subgroup5",
items: [{
text: "subgroup6",
items: [{
text: "subgroup7",
items: [{
text: "subgroup8",
items: []
}]
}]
}]
}]
}]
}]