xxxxxxxxxx
const path = require('path')
const fs = require('fs')
blogs = JSON.parse(fs.readFileSync(path.join(__dirname, '../data/blogs.json')).toString())
xxxxxxxxxx
'use strict';
const fs = require('fs');
fs.readFile('student.json', (err, data) => {
if (err) throw err;
let student = JSON.parse(data);
console.log(student);
});
console.log('This is after the read call');
xxxxxxxxxx
function readJsonFile(file) {
let bufferData = fs.readFileSync(file)
let stData = bufferData.toString()
let data = JSON.parse(stData)
return data
}
xxxxxxxxxx
const fs = require("fs");
var posts = [];
fs.readFile('./data/posts.json', 'utf8', (err, data) => {
if (err) throw err;
posts = JSON.parse(data);
});
xxxxxxxxxx
// Read Synchrously
var fs = require("fs");
console.log("\n *START* \n");
var content = fs.readFileSync("content.txt");
console.log("Output Content : \n"+ content);
console.log("\n *EXIT* \n");
xxxxxxxxxx
const ciqlJson = require("ciql-json")
ciqlJson
.open("file.json")
.set("address", {town : "", city : ""})
.save()