Skip to content

Instantly share code, notes, and snippets.

@radjivF
Last active August 29, 2015 14:13
Show Gist options
  • Save radjivF/e2125b8f1bbf46d44e75 to your computer and use it in GitHub Desktop.
Save radjivF/e2125b8f1bbf46d44e75 to your computer and use it in GitHub Desktop.
Read a Json File
//modules required
var jf = require('jsonfile')
var util = require('util')
var fs = require('fs');
var file = 'name_file.json'
function readJSON(file) {
fs.readFile(file, function (err, data) {
if (err) {
console.log('Error: ' + err);
return;
}
jsonData = JSON.parse(data);
jsonString= JSON.stringify(jsonData);
console.log(jsonString);
});
}
readJSON(file);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment