javascript - How to write this in json format? -


i have code stores data in array. want output on json format. currently, can convert input data json i'm not sure how change code works object. example code on lines :

target = (children[p] || (children[p] = [])); 

and

target.push({value:item}); 

any ideas?

for (var = 0, len = arry.length; < len; ++i) {   var item = arry[i],       p = item.parent,       target = [];      if(p == rootid) {         target = roots;     }      else {                       target = (children[p] || (children[p] = []));                }      target.push({ value: item }); 

}

you can serialize arbitrary javascript object json string calling json.stringify().

that may or may not want.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -