Js parsing background json is processed into element-ui tree format

the json format returned by the backend is roughly as follows:
{

        eeg:{
            ceg:{pel:{:[["asdfg12345","name"]]}},
            pel:{pee:{:[[11,22],[21,22]]}},
            cay:{pcy:{:[[12,13],[22,23],[11,22]]}},
        },
        :{                
            2:{:{:[[11,22],[21,22]]}},
            1:{
                :{:[[12,13],[22,23],[11,22]]},
                :{
                    :[["as123456fgh","name"],["asd123456fgh","name"]]
                }
            },
        },
        :{                
            cb2:{c:{d:[[11,22],[21,22]]}},
            cb3:{c:{d:[[12,13],[22,23],[11,22]]}},
        }
    };


I want to process it into the format used by element ui tree components; for example:

    [{
        Name:"eeg",
        Children:[{
            Name:"ceg",
            Children:[{
                Name:"pel",
                Children:[{
                    Name:"",
                    Children:[{
                        Id:"asdfg12345",
                        Name:"name"
                    }]
                }]
            }]
        },{
            Name:"pel",
            Children:[{

            }]
        }]
    },{
        Name:"",
        Children:[{

        }]
    },{
        Name:"",
        Children:[{

        }]
    }];

try to nest for in traversal, the final data is always wrong, and some data repeat; ask for advice

Jun.14,2021

solved


the landlord gives the answer

Menu