random memes }

Yet another JSON implementation - Javascript

Picked up the JSON string to/from object implementation from json.org a year or so back (which I see has since changed). Did not care for the pollution of the stock classes with toJSONString() methods (don't care much for the method name either), so implemented the same function as methods scoped within a global JSON namespace:

JSON.toJSON(object) returns string JSON.isJSON(string) returns truth JSON.parseJSON(string) returns object

Perhaps a matter of taste, but I do prefer three functions in an isolated namespace over the approach in the json.org code. The string encoder looked (and is) a shade inefficient. Checked by putting together a test page. Chose the string encoder in json.js from timings in Firefox and IE6 (your results may differ). Barring any editing errors, this should work in IE6/IE7, and Firefox/Mozilla. The GET/POST implementations may be a bit cleaner too.