function formatData(tempObj){
let bigArr = [];
for(let p in tempObj){
let tempArrForeach1 = []
for(let key in tempObj[p]){
//数组层
tempArrForeach1.push(arrToObj(tempObj[p][key]));
}
bigArr.push((tempArrForeach1))
}
return bigArr;
function arrToObj(arr=\[\]){
var outObj = {};
//认为arr数组内Element所有字段一致
Object.keys(arr\[\]).forEach(key=>{
var arrChilds = Array.from(new Set((arr.map(v=>v\[key\])+'').split(',')));
if(arrChilds.length>){
outObj\[key\] = arrChilds;
}else if(arrChilds.length==){
outObj\[key\] = arrChilds\[\]
}
});
return outObj
}
}
手机扫一扫
移动阅读更方便
你可能感兴趣的文章