Edit JSON files with ease.
Install this at your project location.
$ npm i easy-json-editor
Get Easy JSON Editor up and running in just a few lines of code.
const easyJSON = require('easy-json-editor');
const jsonFile = easyJSON.file('foo.json'); //replace this with your JSON file
add(object)
Example:
jsonFile.add({
foo: 'boo',
foo1: 'boo1'
});
remove(key, value) //removes an object where (key = value)
Example:
jsonFile.remove('foo1', 'boo1');
find(key, value) //returns an object where (key = value)
Example:
jsonFile.find('foo', 'boo');
replace(whereKey, whereValue, key, newValue)
//finds an object where (whereKey = whereValue)
//then changes the value at key to newValue
Example:
jsonFile.replace('foo', 'boo', 'foo1', 'changed boo1');