Created
November 7, 2018 22:50
Star
You must be signed in to star a gist
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