Created
May 23, 2013 18:15
-
-
Save carloszaragoza/5638199 to your computer and use it in GitHub Desktop.
This gist to convert a json object to objects separated by rows
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 queryToObject = function(q) { | |
var col, i, r, _i, _len, _ref, _ref2, _results; | |
_results = []; | |
for (i = 0, _ref = q.ROWCOUNT; 0 <= _ref ? i < _ref : i > _ref; 0 <= _ref ? i++ : i--) { | |
r = {}; | |
_ref2 = q.COLUMNS; | |
for (_i = 0, _len = _ref2.length; _i < _len; _i++) { | |
col = _ref2[_i]; | |
r[col.toLowerCase()] = q.DATA[col][i]; | |
} | |
_results.push(r); | |
} | |
return _results; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You need this libraries:
https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js
http://cdnjs.cloudflare.com/ajax/libs/json2/20110223/json2.js
http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.2.2/underscore-min.js