完全初学者在这里。我有jQuery库。我打电话给返回json的api。我想使用jquery库中的parseJSON函数来解析它。简单地说,我不知道如何去做。JSON解析与jquery
我可以找到jQuery库中的函数,它看起来像这样:
parseJSON: function(data) {
if (typeof data !== "string" || !data) {
return null;
}
// Make sure leading/trailing whitespace is removed (IE can't handle it)
data = jQuery.trim(data);
// Attempt to parse using the native JSON parser first
if (window.JSON && window.JSON.parse) {
return window.JSON.parse(data);
}
// Make sure the incoming data is actual JSON
// Logic borrowed from http://json.org/json2.js
if (rvalidchars.test(data.replace(rvalidescape, "@")
.replace(rvalidtokens, "]")
.replace(rvalidbraces, ""))) {
return (new Function("return " + data))();
}
jQuery.error("Invalid JSON: " + data);
},
我如何通过发送我的JSON?