javascript - convert string array from json sublist -


i have sublist in json response, as

"sublist" : {     "102" : "core_java(23)",     "103" : "oracle(12)",     "111" : "ruchek(15)",     "104" : "ist-examportal(20)",     "105" : "cybersecurity(30)" } 

i want make this

var jsonsource = '[{         "id" : 102,         "subname" : "core_java(23)"     }, {         "id" : 103,         "subname" : "oracle(12)"     }, {         "id" : 111,         "subname" : "ruchek(15)"     }, {         "id" : 104,         "subname" : "ist-examportal(20)"     }, {         "id" : 105,         "subname" : "cybersecurity(30)"     }]'; 

help me using javascript. thank in advance.

you can for-in loop.

var result = [];  for(var property in sublist){    if(sublist.hasownproperty(property)){       result.push({id: property, subname: sublist[property]});    } } 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -