This is the source$.parseJSON
function (data) {
if (typeof data !== "string" || !data) {
return null;
}
data = jQuery.trim(data);
if (window.JSON && window.JSON.parse) {
return window.JSON.parse(data);
}
if (rvalidchars.test(data.replace(rvalidescape, "@").replace(rvalidtokens, "]").replace(rvalidbraces, ""))) {
return (new Function("return " + data))();
}
jQuery.error("Invalid JSON: " + data);
}
I find it difficult to understand the following backups
return (new Function("return " + data))();
as well (this one is not in jQuery)
return (eval('('+ data + ')')
I would like to know these things
- How does this debugging effect really work?
- Why is eval not used in reserve? (This is not faster than
new Function())
source
share