我有一个如下的树对象,如果它是空的,我正在尝试删除 items 数组属性。我不确定执行此操作的最佳方法?
我正在考虑遍历密钥,检查属性,然后使用删除delete myJSONObject[prop]
...欢迎任何想法/想法?
[{
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: []
}]
}]
}]
}]
}]
}]