views:

113

answers:

2

I know of YUI who has a JSON.stringify utility and also of JSON2 from json.org.

What are other good implementations of JSON.stringify?

It should also work in IE6, IE7 and not depend on a framework.

If it depends on anything this should be easily included all in one file.

Edit: I could easily use jquery-json, which was suggested in the comments of the accepted answer. It did what I wanted. (It depends on jquery but that was easily solved)

+1  A: 

Well, I would recommend you to stay with the JSON2 library, it is really small (~2.5K minified), and it uses native implementations if available.

This small standalone library is also compatible with the JSON object described in the ECMAScript 5 Edition Standard.

CMS
thank you. so don't you know of other libraries? karlthorwald - aka -
Yes, I know some other implementations, but they are library-dependent, like [jquery-json](http://code.google.com/p/jquery-json/) or the built-in JSON support added to [PrototypeJS](http://www.prototypejs.org/learn/json).
CMS
A: 

Consider "json-sans-eval". I'm using this in Myna now because it is super fast, ECMAScript 5 conformant, and most importantly, unlike JSON2, it does not use eval() so there is no danger of someone abusing the JSON spec to execute trojan JavaScript code.

Mark Porter
thank you. does it depend on anything external? - karthorwald - aka
Nope! It is raw JS code.
Mark Porter
This means it is the answer to the question :-) I will try it out soon. karlthorwald – aka