You can use this module for updating your json files in easiest way :)
Install json-update-data
npm install json-update-data
const Jud = require("json-update-data");
const file = "/tmp/data.json";
const data = [
{name: "Jeff"}
];
Jud.writeData(file, data);
const Jud = require("json-update-data");
const file = "/tmp/data.json";
const newData = [
{name: "Jeff"}
];
Jud.pushData(file, newData);
const Jud = require("json-update-data");
const file = "/tmp/data.json";
// 2nd parameter : key name in object
// 3nd parameter : Value that assigned to that key
Jud.deleteData(file, "name", "Jeff");
const Jud = require("json-update-data");
const file = "/tmp/data.json";
// 2nd parameter : key name in object
// 3nd parameter : Value that assigned to that key
Jud.deleteAllData(file, "name", "Jeff");