javascript - how to restructure a array of arrays into a array of objects -


i need structuring new json array of objects. starting array of arrays. need end array of objects. javascript or linq.js work perfectly. thanks

this starting with

var needtochangethisarray = [         [1558, 219561],         [2520, 438218],         [3482, 656874],         [4444, 875531],         [5406, 1094187] ]; 

this how array needs structured

var needstolooklikethisarray = [ { "name": "arbor vista - arbor custom homes", "subid": "10394", "bldid": "8598" }, { "name": "arbor vista - dr horton - (or)", "subid": "10394", "bldid": "8597" }, { "name": "copper canyon estates - brentwood homes", "subid": "9048", "bldid": "16737" }`enter code here` ]; 

so need end this

var needtoendupwiththisarray = [ { "sqft": "1558", "price": "219561" }, { "sqft": "2520", "price": "438218" }, { "sqft": "3482", "price": "656874"  }, { "sqft": "4444", "price": "875531" }, { "sqft": "5406", "price": "1094187" } ]; 

is sufficient?

needtoendupwiththisarray = needtochangethisarray.map(function(a) {   return {     sqft: a[0],     price: a[1]   }; }); 

Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -