Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to transpose json data

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;

},
Comment

PREVIOUS NEXT
Code Example
Javascript :: npm image to LM hash 
Javascript :: set up chrome dev tools adonisjs 
Javascript :: change dxform label angular 
Javascript :: "when.promise" async await 
Javascript :: mvc form client side validation result callback 
Javascript :: processing an express form with node-postgres 
Javascript :: react native app slow lagging image 
Javascript :: lemon get node from id 
Javascript :: activejs 
Javascript :: select coordinates of image 
Javascript :: vendor bundle base js and bootstrap min js conflict 
Javascript :: keyup.enter will work in mac 
Javascript :: mongoose reference another model 
Javascript :: map.getIn gives whole data if prop missing in js 
Javascript :: winston exclude routes 
Javascript :: simple javascript router 
Javascript :: angular injector.create example 
Javascript :: jquery automatically click message alert 
Javascript :: puppeteer wait for select[name= 
Javascript :: destructure object exlude one 
Javascript :: open lightbox in backend 
Javascript :: using slice and reduce together in javascript 
Javascript :: react s.a.createElement("div",{className:"d-none d-lg-flex flex-content"},s.a.createElement(u.a.Body,{noScroll:!0} 
Javascript :: chrome back button click event react 
Javascript :: how to made disktop program on react website 
Javascript :: convert class to functional component online 
Javascript :: Ambobulamblation 
Javascript :: material ui notify 
Javascript :: momen js get time zone code from location name 
Javascript :: https://discord.com/api/guilds/845154482256871435/widget.json 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =