我想您将JSON.parse JSON文件进行比较,在这种情况下
require会更好,因为它将立即解析该文件并进行同步:
var obj = require('./myjson'); // no need to add the .json extension如果您使用该文件有成千上万的请求,则在请求处理程序之外一次请求它,就是这样:
var myObj = require('./myjson');request(options, function(error, response, body) { // myObj is accessible here and is a nice Javascript object var value = myObj.somevalue; // compare response identifier value with json file in node // if identifier value exist in the json file // return the corresponding value in json file instead});


