Created
May 5, 2017 07:03
-
-
Save beepony/4bcea7dc13ab75becbf0437de8ce04ca to your computer and use it in GitHub Desktop.
使用 Node 解析 Json 格式的文件
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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