Skip to content

bwowsersource/jsonian

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

A nodejs module to persist json in file

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published