Javascript – JSON.stringify() and JSON2.stringify() difference

javascriptjson

I downloaded the JSON2.js from https://github.com/douglascrockford/JSON-js/blob/master/json2.js and it does not have implementation for JSON2.stringify()

To be able to call a wcf service from jquery, I am using a helper class that uses JSON2.stringify()

What's the difference between the two and where do I get JSON2?

Best Answer

if you read the file you linked to it mentions

This file creates a global JSON object containing two methods: stringify and parse.

JSON.stringify(value, replacer, space) ...  
JSON.parse(text, reviver) ..

So the object is JSON and not JSON2 ...

[update]

I assume you use the code from this article : jQuery AJAX calls to a WCF REST Service

If you take the time to read it all, he mentions that he is using a hacked version to handle the encoding he wants.. and points to a zip file with his version .. so look at the JSON encoding section in that article..