如何在深度 = 1 的对象树中返回给定节点(键名)的子节点,仅表示第一个子节点。
具体问题:
所以这是一个示例数据对象......
{
"1753": {
"1755": {
"1758": {
"1762": "1753_1755_1758_1762",
"1760": "1753_1755_1758_1760",
"1764": "1753_1755_1758_1764",
"1761": "1753_1755_1758_1761"
},
"1759": {
"1762": "1753_1755_1759_1762",
"1760": "1753_1755_1759_1760",
"1764": "1753_1755_1759_1764",
"1761": "1753_1755_1759_1761"
}
},
"1756": {
"1758": {
"1762": "1753_1756_1758_1762",
"1760": "1753_1756_1758_1760",
"1764": "1753_1756_1758_1764",
"1761": "1753_1756_1758_1761"
},
"1759": {
"1762": "1753_1756_1759_1762",
"1760": "1753_1756_1759_1760",
"1764": "1753_1756_1759_1764",
"1761": "1753_1756_1759_1761"
}
},
"1757": {
"1758": {
"1762": "1753_1757_1758_1762",
"1760": "1753_1757_1758_1760",
"1764": "1753_1757_1758_1764",
"1761": "1753_1757_1758_1761"
},
"1759": {
"1762": "1753_1757_1759_1762",
"1760": "1753_1757_1759_1760",
"1764": "1753_1757_1759_1764",
"1761": "1753_1757_1759_1761"
}
}
},
"1754": {
"1755": {
"1758": {
"1763": "1754_1755_1758_1763"
}
},
"1756": {
"1758": {
"1763": "1754_1756_1758_1763"
}
},
"1757": {
"1758": {
"1763": "1754_1757_1758_1763"
}
}
}
};
对象的每一级代表页面上的一个下拉菜单。
我需要做的是,当有人从下拉菜单之一中选择某些内容时,我需要返回所有剩余菜单的可能性..
例如,假设我从下拉列表 3 中选择值“1758”(因为它是对象中的第三级),请执行以下操作:
I would need to return info stating that because I selected "1758" from dropwdown-3...
-dropdown-1 can be 1753, 1754.
-dropdown-2 can be 1755,1756,1757
-dropdown-3 can remain unchanged
-dropdown-4 can be 1762,1760,1764,1761,1763
到目前为止,我已经能够实现这么多......当这种情况发生某种组合时,问题就出现了:
I have selected option "1758" from dropdown-3, AND THEN SELECTED "1754" from dropdown-1...
-dropdown-1 has the most recent selected value, it can remain unchanged
-dropdown-2 can be 1755,1756,1757
-dropdown-3 is set, but can still have its possible values modified & checked for accuracy
-dropdown-3 can be only 1758
-dropdown-4 can be only 1753
这是一个示例对象,我所有的对象都将具有不同的深度和复杂性......我已经做了很多尝试,希望有人可以向我展示光线:)
谢谢