fs读取某个json文件的数据

时间:2022-12-11 19:49:36
/**
* Created by Administrator on 2016/7/12.
* 流数据
*/
var fs = require('fs');
var stream = fs.createReadStream('./obd.json');
var data = "";
stream.on('data',function(chrunk){//将数据分为一块一块的传递
console.log(chrunk);
console.log(chrunk.toString());
data += chrunk;
});
stream.on('end',function(){
console.log(data);
console.log(data.toString()); console.log('finished!!!!');
});