awesome-json
About
awesome-json is a simple system for reading JSON (plus BSON, YAML, ETF, and MsgPack) files, and automatically writing to the JSON (or BSON/YAML/ETF/MsgPack) file whenever the object is updated. awesome-json supports gzip compression as well.
Installation
npm install --save awesome-json
API
read(filename, [options], callback)
Returns: Promise
options
fs
: any fs module backwards compatible withfs
space
: (JSON only) space argument accepted by JSON.stringifyencoder
: a custom encoder to use while parsing and writing to the fileencoding
: encoding to use while reading the filewriteFrequency
(default: 5000): the length of the interval to write changes in milliseconds, writes immediately if0
Reads a JSON file, and watches for changes. Automatically appends .json
if the file isn't found.
const json = ; json;
readSync(filename, [options])
Returns: Object
options
fs
: any fs module backwards compatible withfs
space
: (JSON only) space argument accepted by JSON.stringifyencoder
: a custom encoder to use while parsing and writing to the fileencoding
: encoding to use while reading the filewriteFrequency
(default: 5000): the length of the interval to write changes in milliseconds, writes immediately if0
Reads a JSON file, and watches for changes. Automatically appends .json
if the file isn't found.
const json = ; const contents = json; contentsbaz = 1; // This change is automatically written to the file.