📜  嵌套 json 数组 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:15.328000             🧑  作者: Mango

代码示例1
function arrayConvert(json){
    var arr = [];
    for(index in json){
        var obj = json[index];
        var key = null;
        while(typeof obj == 'object'){
            for(ind in obj){
                if(key == null) key = ind;
                obj = obj[ind];
            }
        }
        arr.push({'key':key, 'val':obj});
    }
    return arr;
}