
Product
Introducing Repository Access Permissions and Custom Roles
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.
A Node.js module for reading/modifying/writing JSON files.
$ npm install json-file
var json = require('json-file');
// Load a JSON file
var file = json.read('./package.json');
// Read and write some values
file.get('version'); // eg. "1.0.0"
file.get('repository.type'); // eg. "git"
file.set('description', 'Some new description');
// The raw data
console.log(file.data);
// Write the updates to the file
file.writeSync();
A shortcut for creating a json.File object and loading the file contents.
// This...
var file = json.read('/a/b/c');
// Is equivilent to this...
var file = new json.File('/a/b/c');
file.readSync();
// Likewise, this...
var file = json.read('/a/b/c', function() {
// ...
});
// Is equivilent to this...
var file = new json.File('/a/b/c');
file.read(function() {
// ...
});
JSON File object constructor. Takes a path to a JSON file.
var file = new json.File('/path/to/file.json');
Reads the JSON file and parses the contents.
file.read(function() {
//
// Now you can do things like use the .get() and .set() methods
//
});
Reads the JSON file and parses the contents synchronously.
Write the new contents back to the file.
file.write(function() {
//
// Your JSON file has been updated
//
});
Write the new contents back to the file synchronously.
Get a value from the JSON data.
file.get('foo'); // === file.data['foo']
file.get('foo.bar.baz'); // === file.data['foo']['bar']['baz']
Set a value in the JSON data.
file.set('foo', 'bar');
file.set('a.b.c', 'baz');
The set method returns the file object itself, so this method can be chained.
file.set('a', 'foo')
.set('b', 'bar')
.set('c', 'baz');
FAQs
A module for modifiying JSON files
The npm package json-file receives a total of 533 weekly downloads. As such, json-file popularity was classified as not popular.
We found that json-file demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.

Product
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.

Product
Socket Firewall blocks malicious VS Code and Open VSX extensions before install, protecting developers from compromised editor marketplaces.