Commit ff3645ee authored by jeresig's avatar jeresig

Try to use the native JSON parser in all cases and fallback to the old...

Try to use the native JSON parser in all cases and fallback to the old 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.
parent 3f648c4e
......@@ -579,9 +579,11 @@ jQuery.extend({
// Get the JavaScript object, if JSON is used.
if ( type === "json" ) {
if ( typeof JSON === "object" && JSON.parse ) {
// Try to use the native JSON parser first
try {
data = JSON.parse( data );
} else {
} catch(e) {
data = (new Function("return " + data))();
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment