Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I'm using JSON.Stringify and JSON.parse everywhere and it works fine with Firefox. It's working no more with IE9 nor does it work in IE8. What can I do?

like image 982
saurabh ranu Avatar asked Aug 22 '11 10:08

saurabh ranu


People also ask

Why JSON Stringify does not work on array?

The JSON array data type cannot have named keys on an array. When you pass a JavaScript array to JSON. stringify the named properties will be ignored. If you want named properties, use an Object, not an Array.

Is JSON parse opposite of JSON Stringify?

JSON. stringify() is the opposite of JSON. parse(), which converts JSON into Javascript objects.

What is the function of JSON Stringify and JSON parse ()?

The JSON. parse() function is used to convert a string into a JavaScript object while the JSON. stringify() function is used to convert a JavaScript object into a string.

Does JSON Stringify call toJSON?

JSON.stringify() calls toJSON with one parameter, the key , which has the same semantic as the key parameter of the replacer function: if this object is a property value, the property name. if it is in an array, the index in the array, as a string. if JSON.stringify() was directly called on this object, an empty string.


1 Answers

JSON.stringify starts with a lower-case s. Both stringify and parse are available in IE8+, but only in standards mode.

Prepend your document with <!DOCTYPE html> if you're currently using quirks mode. Also, watch the capitalization of the JavaScript methods you call - all built-in ones start with a lower-case character.

like image 157
phihag Avatar answered Oct 06 '22 09:10

phihag