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

Change php variable from jquery value using ajax (same page) -

How can I fetch data from a web server in an android application? -

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