Currently I'm writing a JavaScript file and have the following line:
var res = "JSON=" + JSON.stringify(result);
result is being set just above this line. The issue I'm having is that IE8 (IE8 only, that is) is reporting to me that JSON is undefined somehow. I'm not sure what to make of this since, as I understood it, IE8 is a browser that implemented JSON support. Does anyone have any idea what might be going on?
The JSON-unsafe values on the other hand return : undefined if they are passed as values to the method. null if they are passed as an array element. nothing if passed as properties on an object.
All modern browsers support native JSON encoding/decoding (Internet Explorer 8+, Firefox 3.1+, Safari 4+, and Chrome 3+). Basically, JSON. parse(str) will parse the JSON string in str and return an object, and JSON. stringify(obj) will return the JSON representation of the object obj .
JSON. stringify will omit all object attributes that are undefined .
Make sure you're actually in IE 8 mode by using the preferred method, a standards doctype...
<!DOCTYPE html>
...or the undesired method, the X-UA-Compatible
meta tag/header...
<meta http-equiv="X-UA-Compatible" content="IE=EDGE" />
See Defining Document Compatibility for more information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With