Skip to content

Instantly share code, notes, and snippets.

@Constellation
Created July 9, 2011 07:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Constellation/1073427 to your computer and use it in GitHub Desktop.
Save Constellation/1073427 to your computer and use it in GitHub Desktop.
print(JSON.stringify([1,2,3], function replacer(key, value) {
if (!Array.isArray(value)) {
return value;
}
var len = value.length;
var result = { length: len };
for (var i = 0; i < len; ++i) {
// Array holeを認識するかはお好みで...
result[i] = value[i];
}
return result;
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment