Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Try to use the native JSON parser in all cases and fallback to the ol…
…d technique otherwise. This allows us to also handle cases where the JSON parser is unable to parse JSON-like strings correctly (e.g. {foo:bar}) which is something that worked before but would stop working with the switch to the new parser.
- Loading branch information
ff3645e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i've run into a known IE8 issue with its native parser's inability to serialize empty values of DOM elements. details here:
http://blogs.msdn.com/jscript/archive/2009/06/23/serializing-the-value-of-empty-dom-elements-using-native-json-in-ie8.aspx
just a heads up,
Leon
ff3645e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just out of curiosity; is double quotes required (") for keys or will single quotes suffice?
ff3645e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JSON strings only use double quotes. See json.org for the full (very tiny) spec.
ff3645e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dunno why my first comment didnt show up...reposting w/tinyurl...
i've run into a known IE8 issue with its native parser's inability to serialize empty values of DOM elements.
details here: http://tinyurl.com/m2j294
just a heads up,
Leon
ff3645e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I know, was just wondering what would "work"
ff3645e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IE8: JSON.parse("{ 'a':1 }") ---> Syntax Error
CHROME: JSON.parse("{ 'a':1 }") ---> OK
FF: JSON.parse("{ 'a':1 }") ---> Syntax Error
OPERA 10.10: JSON.parse("{ 'a':1 }") ---> Undefined variable JSON
SAFARI 4.0.4: JSON.parse("{ 'a':1 }") ---> Syntax Error
ff3645e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
http://groups.google.com/group/jquery-dev/browse_thread/thread/c70e0ceece63da01/df0d0572f49b491a#df0d0572f49b491a