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

json-file-plus

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
j

json-file-plus

Read from and write to a JSON file, minimizing diffs and preserving formatting.

0.2.3
100

Supply Chain Security

100

Vulnerability

84

Quality

78

Maintenance

100

License

Deprecated

Maintenance

The maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.

Found 1 instance in 1 package

Dependencies have 2 high and critical alerts.

Critical CVE

Version published
Weekly downloads
118K
4.82%
Maintainers
1
Weekly downloads
 
Created
Issues
3

#json-file-plus Version Badge

Build Status dependency status dev dependency status

npm badge

A module to read from and write to JSON files, without losing formatting, to minimize diffs.

Example

var jsonFile = require('json-file-plus');
var path = require('path'); // in node-core
var filename = path.join(process.cwd(), 'package.json');
jsonFile(filename, function (err, file) {
	if (err) { return doSomethingWithError(err); }

	file.data; // Direct access to the data from the file
	file.format; // extracted formatting data. change at will.

	file.get('version'); // get top-level keys, synchronously
	file.get('version', callback); // get top-level keys, asynchronously
	file.get(); // get entire data, synchronously
	file.get(callback); // get entire data, asynchronously

	/* pass any plain object into "set" to merge in a deep copy */
	/* please note: references will be broken. */
	/* if a non-plain object is passed, will throw a TypeError. */
	file.set({
		foo: 'bar',
		bar: {
			baz: true
		}
	});

	/* change the filename if desired */
	file.filename = path.join(process.cwd(), 'new-package.json');

	/* Save the file, preserving formatting. */
	/* Callback will be passed to fs.writeFile */
	file.save(fsWriteFileCallback);
});

Tests

Simply run npm test in the repo

FAQs

Package last updated on 07 Dec 2013

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