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
Menu