0.0.1 • Published 2 years ago

jsonian v0.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

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('./testTable.json'); // 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.