javascript - How to traverse the tree structure json of N-level child nodes to determine that the length of the deepest children is 0?
PHP中文网
PHP中文网 2017-06-12 09:24:12
0
1
777

data= {

    "name": "root",
        "size": "4",
        "Rate": "4",
        "level": "3",
        "children": [
    {
        "name": "C1",
        "size": "8",
        "Rate": "8",
        "level": "4",
        "children": [
            {
                "name": "C11",
                "size": "8",
                "Rate": "8",
                "level": "5",
                "children":[]
            }
        ]
    }
]
}
PHP中文网
PHP中文网

认证高级PHP讲师

reply all(1)
Peter_Zhu

js judgment? ?

Use hasownproperty('children') to encapsulate whether the node contains children

Then traverse or while judgment, if there are no children at this time, it is the end, and then judge it

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!