showing results for - "how to transpose json data"
Jacob
24 Jan 2018
1transpose : function(oTreeAll) {
2
3    var keys = [];
4    var i = 0;
5    for ( var key in oTreeAll[i]) {
6        keys.push(key);
7    }
8
9    console.log(keys);
10
11    var newObj = {
12        d : []
13    };
14
15    newObj['length'] = oTreeAll.length;
16    for (var k = 0; k < oTreeAll.length; k++) {
17        var obj = {};
18        for ( var cnt in keys) {
19            obj[keys[cnt]] = "";
20        }
21        newObj.d.push(obj);
22    }
23
24    for (var k = 0; k < oTreeAll.length; k++) {
25        for (var j = 0; j < oTreeAll.length; j++) {
26            newObj.d[k][keys[j]] = oTreeAll[j][keys[k]];
27        }
28    }
29
30    console.log(newObj);
31            return newObj;
32
33},