Created
November 7, 2018 22:50
-
-
Save mitsuhiko/7e784becb001225ae7df7df15b93512f to your computer and use it in GitHub Desktop.
This file contains 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
<!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