How to design the json level 4 menu with the first layer?

[{
                      "name": "",
                    },
                     {
                      "name": "",
                    },
                      {
                      "name": "",
                    },  
                    {
                      "name": "",
                    },
                     {
                      "name": "",
                    },
                      {
                      "name": "",
                    },
                     {
                      "name": "",
                    },
                     {
                      "name": "",
                    }]

how can this layer-by-layer json, be linked quickly? Quickly find the level of the menu, and the order

Sep.17,2021

set the id of each menu object and its parent id, and then transform the data into a tree


const MENU=[
    {name:"1", id:"level_1_1", ...},
    {name:"2", id:"level_1_2", ...},
    {name:"1", id:"level_2_1", parent:"level_1_1", ...},
    {name:"2", id:"level_2_2", parent:"level_1_1", ...},
    {name:"3", id:"level_2_3", parent:"level_1_2", ...},
    {name:"4", id:"level_2_4", parent:"level_1_2", ...}
];

//
load() {
    const LEVEL_1 = MENU.filter(menu => menu.id.indexOf("level_1_")===0);
    //...
}


//
menuClicked(selectedMenu){
    const LEVEL_2 = MENU.filter(menu => menu.parent === selectedMenu.id);
    //...
}

//...

this photo is not quite in line with the current programming style.


[
    {
        name:"a",
        child:[
            {
                name:"a-1",
                child:[
                    {
                        name:"a-1-1",
                        child:null
                    },
                    {
                        name:"a-1-2",
                        child:null
                    }
                ]
            },
            {
                name:"a-2",
                child:null
            }
        ]
    }
]

use this sequence to express it

data['1-1-2-1-3'] = XXX
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-1ea1434-1b46.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-1ea1434-1b46.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?