You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

jsondata

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsondata

A module that saves and loads json data from a file

1.1.1
latest
Source
npmnpm
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

JsonData

Build Status

A module that saves and loads json data from a file. You can also modify the object loaded.

Installation

> npm install --save jsondata

Usage

In order to declare JsonData, you need to

var JsonData = require("jsondata");
var jsondata = new JsonData();

There are 4 methods available:

  • load
  • add
  • remove
  • save

And to get the data loaded, it is simply

jsondata.data // object that is jsondata

load

Loads data from a file

jsondata.load(/** filename **/, function(error, obj){
    if (err) throw err;
    assert(jsondata.data, obj); // obj is the loaded object
});

add

Adds an object to jsondata.data

jsondata.add(/** object to add to jsondata.data **/, function(){
    /** jsondata.data has been modified **/
});

remove

Removes a key from the object that is jsondata.data

jsondata.remove(/** key to be removed **/, function(){
    /** jsondata.data has been modified **/
});

save

Saves object to a file

jsondata.save(/** filename **/, function(error, str){
    if (err) throw err;
    assert(JSON.stringify(jsondata.data), str); // str is the stringify version of the data that was saved into the file
});

Versions

1.1.0

  • load will create if it doesn't exist

1.0.1

  • Allow to not have callbacks

1.0.0

  • First commit

Keywords

json

FAQs

Package last updated on 27 Aug 2015

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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.