Created
April 9, 2011 10:36
-
-
Save Qard/911297 to your computer and use it in GitHub Desktop.
JSON.stringify that retains functions. Simple, but handy.
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
JSON.fstringify = function(object) { | |
return JSON.stringify(object, function(key, value){ | |
if (typeof value == 'function') { | |
return value.toString(); | |
} | |
return value; | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment