Answers for "how to update a json file javascript"

0

how to update a json file javascript

const fs = require('fs');
const fileName = './file.json';
const file = require(fileName);
    
file.key = "new value";
    
fs.writeFile(fileName, JSON.stringify(file), function writeJSON(err) {
  if (err) return console.log(err);
  console.log(JSON.stringify(file));
  console.log('writing to ' + fileName);
});
Posted by: Guest on July-09-2021

Code answers related to "how to update a json file javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language