json-updater
Inserts new object to your json file without overwriting the content.
why use this?
json-updater
doesn't rewrite the whole file but appends the new object to your json file object, which makes it much faster.
installation
npm install --save json-updater
API
insert(filename, obj[,space], callback)
obj
object(s) to insert
The optional space
argument formats your obj
. Default 0
spaces.
Using default space:
var jsonUpdater = ;var file = __dirname + '/users.json'; var obj = "1": "first_name": "Will" "last_name": "Smith" ; //you can also insert multiple objectsvar multiObj = "2": "first_name": "Google" "last_name": "Chrome" "3": "first_name": "Mozilla" "last_name": "Firefox" "arr": "foo" "bar" jsonUpdater;
With space or tab:
jsonUpdater; jsonUpdater;
read(filename[,space], callback)
The callback gets two arguments (err, data)
where data
is the content of the file
The optional space
argument formats the data
from callback.
jsonUpdater;