Answers for "node.js edit json filer"

5

edit json via nodejs

//Using edit-json-file for NodeJS, based off the NPM documentation for edit-file-json
const editJsonFile = require("edit-json-file");
let file = editJsonFile(`${__dirname}/filename.json`);
file.set("name", "value");
file.save();
file = editJsonFile(`${__dirname}/filename.json`, {
    autosave: true
});
Posted by: Guest on October-02-2020
2

nodejs manipulate file json write

//change the value in the in-memory object
content.val1 = 42;
//Serialize as JSON and Write it to a file
fs.writeFileSync(filename, JSON.stringify(content));
Posted by: Guest on December-07-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language