📅  最后修改于: 2022-03-11 15:02:00             🧑  作者: Mango
transpose : function(oTreeAll) {
var keys = [];
var i = 0;
for ( var key in oTreeAll[i]) {
keys.push(key);
}
console.log(keys);
var newObj = {
d : []
};
newObj['length'] = oTreeAll.length;
for (var k = 0; k < oTreeAll.length; k++) {
var obj = {};
for ( var cnt in keys) {
obj[keys[cnt]] = "";
}
newObj.d.push(obj);
}
for (var k = 0; k < oTreeAll.length; k++) {
for (var j = 0; j < oTreeAll.length; j++) {
newObj.d[k][keys[j]] = oTreeAll[j][keys[k]];
}
}
console.log(newObj);
return newObj;
},