您不需要任何库,香草javascript中的所有内容均可用,以获取json文件并进行解析:
function fetchJSonFile(path, callback) { var httpRequest = new XMLHttpRequest(); httpRequest.onreadystatechange = function() { if (httpRequest.readyState === 4) { if (httpRequest.status === 200) { var data = JSON.parse(httpRequest.responseText); if (callback) callback(data); } } }; httpRequest.open('GET', path); httpRequest.send(); }// this requests the file and executes a callback with the parsed result once// it is availablefetchJSonFile('pathToFile.json', function(data){ // do something with your data console.log(data);});


