Skip to content

Instantly share code, notes, and snippets.

@mikefrey
Created July 18, 2013 19:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikefrey/6032129 to your computer and use it in GitHub Desktop.
Save mikefrey/6032129 to your computer and use it in GitHub Desktop.
JSON-Stringifying functions on objects
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