1
0
CompleteNodeJS/playground/1-json.js
Jason Williams 6528d7204a Section 20
2019-08-11 12:15:16 -06:00

12 lines
271 B
JavaScript

const fs = require('fs');
const dataBuffer = fs.readFileSync('1-json.json');
const dataJSON = dataBuffer.toString();
const data = JSON.parse(dataJSON);
data.name = 'Jason';
data.age = 38;
const newJSON = JSON.stringify(data);
fs.writeFileSync('1-json.json', newJSON);