Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
JSON.stringify(o, function (k,v) {
if (v && typeof v === 'object' && !isArray(v)) { // assumes an isArray function
var sorted = {},
keys = [],
key,i,len;
for (key in v) {
if (v.hasOwnProperty(key)) {
keys.push(key);
}
}
keys.sort();
for (i = 0, len = keys.length; i < len; ++i) {
sorted[keys[i]] = v[keys[i]];
}
return sorted;
} else {
return v;
}
}, 4);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.