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

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -