A multi-layer nested json data. I want to take the name value under each children. How can I get it? And the number of nesting layers of this json may increase.

[

]
{
    "children": [
        
    ],
    "users": null,
    "id": "//",
    "name": "",
    "nikeName": null,
    "indexPeople": null,
    "phone": "2232223",
    "mailPhone": "2231113",
    "ade": "",
    "mailNumber": "1232333",
    "parentId": "/"
},
{
    "children": [
        {
            "children": [
                
            ],
            "users": null,
            "id": "//1234/1234565",
            "name": "1234565",
            "nikeName": null,
            "indexPeople": null,
            "phone": "3325663",
            "mailPhone": "3326663",
            "ade": "",
            "mailNumber": "325666",
            "parentId": "//1234"
        }
    ],
    "users": null,
    "id": "//1234",
    "name": "1234",
    "nikeName": null,
    "indexPeople": null,
    "phone": "3325663",
    "mailPhone": "332552",
    "ade": "",
    "mailNumber": "326544",
    "parentId": "/"
},
{
    "children": [
        {
            "children": [
                
            ],
            "users": null,
            "id": "///",
            "name": "",
            "nikeName": null,
            "indexPeople": null,
            "phone": "3325335",
            "mailPhone": "3323663",
            "ade": "",
            "mailNumber": "326322",
            "parentId": "//"
        }
    ],
    "users": null,
    "id": "//",
    "name": "",
    "nikeName": null,
    "indexPeople": null,
    "phone": "3325336",
    "mailPhone": "3325336",
    "ade": "",
    "mailNumber": "326511",
    "parentId": "/"
}

]

Mar.19,2021

write a recursive method to get the name value in children, and you end up with an array, [name1.] Name2, name3.], or is there an object format in the array?


Thank you for the invitation!
the question is how do you use it after you bring it up? If it is a simple extraction, it can be easily implemented recursively, but if you need to put this data into a required format, you may need to do more processing.


let json = [
{
    "children": [
        
    ],
    "users": null,
    "id": "//",
    "name": "",
    "nikeName": null,
    "indexPeople": null,
    "phone": "2232223",
    "mailPhone": "2231113",
    "ade": "",
    "mailNumber": "1232333",
    "parentId": "/"
},
{
    "children": [
        {
            "children": [
                
            ],
            "users": null,
            "id": "//1234/1234565",
            "name": "1234565",
            "nikeName": null,
            "indexPeople": null,
            "phone": "3325663",
            "mailPhone": "3326663",
            "ade": "",
            "mailNumber": "325666",
            "parentId": "//1234"
        }
    ],
    "users": null,
    "id": "//1234",
    "name": "1234",
    "nikeName": null,
    "indexPeople": null,
    "phone": "3325663",
    "mailPhone": "332552",
    "ade": "",
    "mailNumber": "326544",
    "parentId": "/"
},
{
    "children": [
        {
            "children": [
                
            ],
            "users": null,
            "id": "///",
            "name": "",
            "nikeName": null,
            "indexPeople": null,
            "phone": "3325335",
            "mailPhone": "3323663",
            "ade": "",
            "mailNumber": "326322",
            "parentId": "//"
        }
    ],
    "users": null,
    "id": "//",
    "name": "",
    "nikeName": null,
    "indexPeople": null,
    "phone": "3325336",
    "mailPhone": "3325336",
    "ade": "",
    "mailNumber": "326511",
    "parentId": "/"
}
]
let result = JSON.stringify(json).match(/(?<=("name":")).*?(?=")/g)
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b379ab-2c0b3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b379ab-2c0b3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?