Skip to content

Instantly share code, notes, and snippets.

@neilff
Created December 19, 2013 17:14
Show Gist options
  • Save neilff/8042831 to your computer and use it in GitHub Desktop.
Save neilff/8042831 to your computer and use it in GitHub Desktop.
nodejs-create-read-file-example
var fs = require('fs');
var myData = {
name:'test',
version:'1.0'
},
outputFilename = 'my.json';
// Write cache file
fs.writeFileSync(outputFilename, JSON.stringify(myData, null, 4));
// Read cache file
var parsedJson = JSON.parse(fs.readFileSync(outputFilename));
console.log(parsedJson);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment