Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why JSON.stringify giving JSON undefined error?

I am trying to use JSON.stringify in my javascript page (EXTJS) code but it's giving me JSON is undefined error. Error happends only in IE (ver.10). This code will work in FF and Chrome. Below is a sample code that I am trying to use. Why is it failing? This seems like a valid example and works in other browsers. Thanks in advance.

var contact = new Object(); 
contact.firstname = "Joe";
contact.surname = "Smith";
contact.gendere= "male";
var jsonText = JSON.stringify(contact);
like image 968
JS11 Avatar asked Jun 18 '13 15:06

JS11


1 Answers

Use <!DOCTYPE html> if you only need to support IE10. If you need to use earlier versions of IE (some people still need to support IE6) you can use the JS implementation of JSON: https://github.com/douglascrockford/JSON-js

like image 68
SheetJS Avatar answered Oct 10 '22 17:10

SheetJS