ji

json-interface

To load JSON configuration files with permision of read or write, returns an API that allows access to parsed JSON object. If write specified, two methods are attached, save and revert. Implements a cache so the same instance of parsed JSON objects can be

Showing:

Popularity

Downloads/wk

2

Maintenance

No Maintenance Data Available

Package

Dependencies

0

Size (min+gzip)

0.7KB

License

ISC

Type Definitions

Tree-Shakeable

No?

Categories

Deprecated!
A playing/learning project. Not worthy of being on NPM

Readme

README

Adds an API layer on top of JSON config files.

Purpose

  • Simplify loading and saving of json files across a nodejs project
  • Utilises a cache to ensure integrity or data object across multiple node modules.
    • Will return the same object instance of the data to operate upon, unless noCache = true
  • Emulates permissions of read/write upon a JSON file
    • if read: {data : jsonObj}
    • if write: {data:jsonObj, save:fnc, revert:fnc}
  • Version - 0.0.2

Operation

  • jsonConfigInterface = require('json-config-interface')
  • Config files can be loaded with or without .json extension specified
  • Config files can be loaded from:
    • relative dir path jsonConfigInterface.get('./my-config')
    • absolute dir path jsonConfigInterface.get('/path/to/configs/my-config')
    • explicitly defined config directory jsonConfigInterface.setDir('/path/to/configs/'); jsonConfigInterface.get('my-config')
  • Get with methods to save and revert jsonConfigInterface.get('/my-config', 'write')
  • Get a fresh load of config file not from shared cahce jsonConfigInterface.get('/my-config', 'write', true)
  • Purge cache of config file jsonConfigInterface.purge('/my-config')
  • Purge entire cache jsonConfigInterface.purge()

TODO

*json schema validation support

  • sandbox object returns made where write is not specified, as currently a load in read mode can still make edits. (is this possible? some form of JSON parse clone could be used, but it would need to be updated if anywhere else makes a legit edit, how would we watch for that?)

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100