Created
May 26, 2014 21:40
-
-
Save muratpurc/fa9741e30163b3e0c936 to your computer and use it in GitHub Desktop.
JS: JSON.stringify
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
// Helper function to convert JSON to it's string representation | |
var jsonStringify = typeof JSON !== 'undefined' ? JSON.stringify : function(obj) { | |
var arr = []; | |
$.each(obj, function(key, val) { | |
var next = key + ': '; | |
next += (val === Object(val)) ? jsonStringify(val) : val; | |
arr.push(next); | |
}); | |
return '{ ' + arr.join(', ') + ' }'; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment