Created
November 3, 2019 03:46
-
-
Save luisenriquecorona/1032d3897093397e7ec56e9884388e26 to your computer and use it in GitHub Desktop.
Successful parsing requires that the order of the data must be maintained. That being said, it is trivial to convert this format into one that maintains the same attribute names as the first JSON format:
This file contains hidden or 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
function parseJSON(responseText) { | |
var users = []; | |
var usersArray = eval('(' + responseText + ')'); | |
for (var i = 0, len = usersArray.length; i < len; i++) { | |
users[i] = { | |
id: usersArray[i][0], | |
username: usersArray[i][1], | |
realname: usersArray[i][2], | |
email: usersArray[i][3] | |
}; | |
} | |
return users; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment