Json.Stringify() not supported by Internet Explorer 8, Internet Explorer 9.

Today I was testing my ASP.NET MVC app I had prepared, with all browsers, when I run into this problem on Internet Explorer 9. I opened up the Internet Explorer Developer Tool and found an error message in the console. It read JSON is undefined.

After a little search, I came across this thread on stackoverflow. The solution to this was pretty simple.

Solution :

You only need to include a reference to json2.js to your project.

<script type='text/javascript' src='http://cdnjs.cloudflare.com/ajax/libs/json2/20110223/json2.js'>

This json2.js file is present at http://cdnjs.cloudflare.com/ajax/libs/json2/20110223/json2.js or https://github.com/douglascrockford/JSON-js/blob/master/json2.js, you can download this file and include this in your project.

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

Further Reading :

JSON.stringify and JSON.parse not working in IE9?

Is JSON.stringify() supported by IE 8?