Skip to content

Instantly share code, notes, and snippets.

@luisenriquecorona
Created November 3, 2019 03:46
Show Gist options
  • Save luisenriquecorona/1032d3897093397e7ec56e9884388e26 to your computer and use it in GitHub Desktop.
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:
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