A simple JSON stringify function which requires Array.prototype.map method.
The following users provided lots of ideas and improvements of the code.
@Kambfhase, @hartrock, @atk, @haochi, @jed
Actually, I just provided a deficient version at first. The other versions were created by these users(especially @atk). You may see the discussion below.
@adius: doesn't help, because we'll need a.map anyway. A working version (alas, with 214bytes too long) is here:
function s(a,b,c){for(b in(c=a==''+{}&&[])&&a)c.push(s(b)+':'+s(a[b]));return''+a===a?'"'+a.replace(/[\x00-\x32\\]/g,function(x){return'\x'+x.charCodeAt().toString(16)})+'"':a&&a.map?'['+a.map(s)+']':c?'{'+c+'}':a}
I've not yet tested if it still works if you replace
function(x){return'\x'+x.charCodeAt().toString(16)}
withfunction(x){return escape(x).replace(/%/g,'\\x')}
, saving 2 further bytes.