🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

node-file-json

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-file-json

Read JSON from a file and work on it dynamically. You can even use the JSON file as a small database. If file does not exist, one will be created for you.

0.0.8
latest
Source
npm
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

node-file-json

Read JSON from a file and work on it dynamically. You can even use the JSON file as a small database. If file does not exist, one will be created for you.

Usage:

Load JSON file, if it does not exist, it will be created automatically.

var fileJson = require("node-file-json");
var json = new fileJson();
json.load("product.json");

Modify JSON data

json.data.property1 = "First property";
json.data.property2 = {name: "Product name", details: "These are some details."};

Save JSON data

json.save();

Data will be saved in the file as defined in .load() to be read any time.
If any errors occur during loading/creating JSON file, check console log. JSON in file is saved properly with indents. To modify indent value, add it to options, example:

json.load("product.json", {indent: 4});

Clear JSON data

json.clear();

Keywords

node

FAQs

Package last updated on 21 Jan 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts