Last active
October 27, 2021 03:49
-
-
Save NaClYen/bae0b849452e8ca93a5fa0f01edb44a2 to your computer and use it in GitHub Desktop.
nodejs - load json file
This file contains 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
const fs = require('fs'); | |
// 注意此資料會是 byte array | |
let rawdata = fs.readFileSync('./my.json'); | |
console.log(rawdata); | |
let obj = JSON.parse(rawdata); | |
console.log(obj); |
This file contains 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
let obj = require('./my.json'); | |
console.log(obj); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment