Created
March 6, 2012 14:10
-
-
Save lbj96347/1986476 to your computer and use it in GitHub Desktop.
Restructuring JSON
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var m = [{a:'a',b:'b'},{a:'c',b:'d'}]; | |
//regard m as a JSON | |
var img = new Array(); | |
for (x in m ) | |
{ | |
var val = m[x].a; | |
img[x]={img:val,name:val} | |
} | |
//img[0]={img:'a', name :'a'} | |
//img[1]={img:'c', name :'c'} | |
//this is the result we want to get. | |
console.log(img); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment