jsonian

0.0.1 • Public • Published

jsonian

A nodejs module to persist json in file

Install

npm i jsonian

or 

yarn add jsonian

Usage

const jsonian = require('jsonian');

const $table = jsonian('Students'); // file must already exist

$table is proxy to a root object. You can use it to get or set values as usual. Setting functions in jsonian objects can cause errors during serialization. Don't do that.

// './testTable.json' 
{
    "name": "Students"
}
// to read value
var name = $table.name; // "Students"

// to write value to file
$table.name = "New_table_name"; // replaces "Students" in file './testTable.json' 
$table.rows = ["name","class"]; // adds new field "rows" in file './testTable.json'

The $ sign in the begining of $table is an indicator that it is a pure json object (jsonian proxy). I find it useful, to maintain a readable code. If you already use $ for something else feel free to come up with your own convention.

Why?

No need to use getters and setters.

Readme

Keywords

none

Package Sidebar

Install

npm i jsonian

Weekly Downloads

2

Version

0.0.1

License

MIT

Unpacked Size

3.42 kB

Total Files

6

Last publish

Collaborators

  • acashjos