hookex
12/11/2019 - 2:23 AM

node code

import * as fs from 'fs';

function writeJSON(json: JSON, filePath = './data.json') {
    let data = JSON.stringify(json);
    fs.writeFileSync(filePath, data);
}

fs.readFile('student.json', (err, data) => {
    if (err) throw err;
    let student = JSON.parse(data);
    console.log(student);
});