November 16, 2010

JSON Support in IE8: Not So Much

These days most browsers out there have some kind of native support for working with JSON objects. Except Internet Explorer, that is.

Despite the fact that this blog post from 2 years ago states that there is native JSON support in IE8, when I tested my application in IE8 last week I still received the old familiar "JSON is undefined" error.

So, it seems that the native JSON support in IE8 is not really there, and thus I'm back to referencing json2 from http://json.org/json2.js instead.

2 comments:

Luca said...

You're wrong. IE8 does support native JSON. What exactly is your issue?

Driscoll Web Development said...

Not really. Native support seems to work okay in some contexts, but it's not working at all for me in callbacks. I have a callback in document scope that's supposed to parse a JSON string using JSON.parse(). Without an explicit reference to json2.js, I get a "'JSON' is undefined" error at the point of execution for JSON.parse. With an explicit reference to json2.js I get no error. It's a moot point anyway, as I need to support earlier versions of IE that don't have native JSON support, so I'll need the explicit reference no matter what.