Skip to content

Instantly share code, notes, and snippets.

@beepony
Created May 5, 2017 07:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beepony/4bcea7dc13ab75becbf0437de8ce04ca to your computer and use it in GitHub Desktop.
Save beepony/4bcea7dc13ab75becbf0437de8ce04ca to your computer and use it in GitHub Desktop.
使用 Node 解析 Json 格式的文件
var fs = require('fs');
var file = __dirname + '/config.json';
fs.readFile(file, 'utf8', function (err, data) {
if (err) {
console.log('Error: ' + err);
return;
}
data = JSON.parse(data);
console.dir(data);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment