Skip to content

Instantly share code, notes, and snippets.

@mitsuhiko mitsuhiko/test.html

Created Nov 7, 2018
Embed
What would you like to do?
<!doctype html>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prototype/1.6.0/prototype.min.js"></script>
<script>
(function() {
var originalStringify = JSON.stringify;
JSON.stringify = function stringify() {
var old = Array.prototype.toJSON;
delete Array.prototype.toJSON;
try {
return originalStringify.apply(this, arguments);
} finally {
Array.prototype.toJSON = old;
}
}
})();
console.log(JSON.stringify({"foo": [1, 2, 3]}));
console.log(typeof JSON.parse(JSON.stringify([1])) === 'string' ? 'buggy' : 'not buggy');
</script>
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.