javascript - How to create dynamically a simple json array? -


i know questions exists 100 times, can't transfer solutions code, hope can me. should pretty easy don't working.

this code other variable because of reasons:

my code:

for (var key in array) { } 

the json want:

[{     key: "one",     y: 5 }, {     key: "two",     y: 2 },]; 

pseudo json:

[{     key: key,     y: array[key].data },{     key: key,     y: array[key].data; },]; 

you can try solution:

var data = []; (var key in array) {   data.push({     key :  key,     y : array[key].data   }); }  console.log(data); 

but, pseudo json:?

demo - see console (chrome) output


Comments

Popular posts from this blog

Upgrade php version of xampp not success -

amazon web services - S3 and apache mod_proxy with basic authentication -

powershell - This solution contains one or more assemblies targeted for the global assembly cache -