Skip to content

Instantly share code, notes, and snippets.

@phpnode
Created May 5, 2012 14:41
Show Gist options
  • Save phpnode/2602984 to your computer and use it in GitHub Desktop.
Save phpnode/2602984 to your computer and use it in GitHub Desktop.
function d(b){e=function(c){return c.replace(/"/,'\\"')};g=function(c){var b=[];for(i=0;i<c.length;i++)b.push(d(c[i]));return b};h=function(b){var f=[];for(a in b)f.push('"'+e(a)+'": '+d(b[a]));return"{"+f.join(",")+"}"};r=Object.prototype.toString.call(b).split(" ").pop().charAt(0);return"S"==r?'"'+e(b)+'"':"N"==r?b:"A"==r?"["+g(b).join(",")+"]":h(b)}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment