json-watch

1.0.2 • Public • Published

node-json-watch

auto reload a json file when it's changed without restart your project

installation

npm install json-watch

usage

var jsonWatcher = require('json-watch');
jsonWatcher.watch('/absolute/path/to/the/file.json');
// then you can use `jsonWatcher.get()` to access your data
console.log(jsonWatcher.get())
// if `file.json` is changed, the value of `jsonWatcher.get()` will auto reload, no need to restart your project

Important: use jsonWatcher.get(), not var json = jsonWatcher.get(); console.log(json);. otherwise the json will not change when the file changed

contact me

csser.me

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i json-watch

      Weekly Downloads

      16

      Version

      1.0.2

      License

      ISC

      Last publish

      Collaborators

      • indooorsman