Created
July 18, 2013 19:13
-
-
Save mikefrey/6032129 to your computer and use it in GitHub Desktop.
JSON-Stringifying functions on objects
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
var obj = { fn:function() { return 'Wooo!' } } | |
JSON.stringify(obj) // '{}' | |
obj.fn.toJSON = function() { return this() } | |
JSON.stringify(obj) // '{"fn":"Wooo!"}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment