Skip to content

Instantly share code, notes, and snippets.

@anmolsukki
Last active May 5, 2020 12:46
Show Gist options
  • Select an option

  • Save anmolsukki/c6d66cde34e8cfd15220d97f6ed75785 to your computer and use it in GitHub Desktop.

Select an option

Save anmolsukki/c6d66cde34e8cfd15220d97f6ed75785 to your computer and use it in GitHub Desktop.
[ NodeJs ] Read Json File ( https://repl.it/@anmolsukki/3ReadJsonFile )
const fs = require("fs");
const dataBuffer = fs.readFileSync("person.json")
console.log(dataBuffer)
console.log(dataBuffer.toString())
const dataJSON = dataBuffer.toString()
const data = JSON.parse(dataJSON)
console.log(data.title)
{ "title": "Ego is the enemy", "author": "Ryan Holiday" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment