![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
json-file-plus
Advanced tools
Read from and write to a JSON file, minimizing diffs and preserving formatting.
A module to read from and write to JSON files, without losing formatting, to minimize diffs.
var jsonFile = require('json-file-plus');
var path = require('path'); // in node-core
var filename = path.join(process.cwd(), 'package.json');
var callback = function (err, result) { /* your code here */ };
/* Note: jsonFile also returns a Promise, if you prefer that to a Node-style callback ("errorback"). */
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. returns a Promise
file.get('version', callback); // get top-level keys. calls the errorback
file.get(); // get entire data. returns a Promise
file.get(callback); // get entire data. calls the errorback
/* 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
}
});
file.remove('description'); // remove a specific key-value pair. returns a Promise
file.remove('description', callback); // remove a specific key-value pair. calls the errorback
/* change the filename if desired */
file.filename = path.join(process.cwd(), 'new-package.json');
/* Save the file, preserving formatting. */
/* Errorback will be passed to fs.writeFile */
/* Returns a Promise. */
file.save(callback).then(function () {
console.log('success!');
}).catch(function (err) {
console.log('error!', err);
});
});
Simply run npm test
in the repo
FAQs
Read from and write to a JSON file, minimizing diffs and preserving formatting.
The npm package json-file-plus receives a total of 66,844 weekly downloads. As such, json-file-plus popularity was classified as popular.
We found that json-file-plus demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.