
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
json-update
Advanced tools
This is a simple way to update (or load) a JSON file. If the JSON file does not exist it will be created (along with a directory structure if those directories don't exist yet).
Uses underscore to extend existing JSON data with the object you specify, overriding anything with an existing property and adding properties if they are new.
NEW: You may change the extend behavior by calling config({deep:true})
before calling update
. This will use deep-extend
instead of
underscore extend to merge the data when you call update
.
New version supports promises (and async/await with babel).
npm install json-update
Updating a JSON file (and return the new object) (with promise):
json = require('json-update');
json.update('data.json',{test:10})
.then(function(dat) {
console.log(dat.test)
});
With async/await (you must use babel
with babel-polyfill
etc. as with all use of async/await):
import {update, load} from 'json-update';
async function test() {
await update('t.json', {x:2});
let dat = await load('t.json');
console.log(dat.x);
}
test().then(()=> {}).catch( e=> {console.error(e)});
With a callback:
json = require('json-update')
json.update('data.json', { test: 'value x' }, function(err, obj) {
if (typeof err !== "undefined" && err !== null) {
console.log("Error updating json: " + err.message);
}
console.log(obj);
});
Loading a JSON file (note that in the case of loading a valid JSON file must already exist):
json = require('json-update')
json.load('data.json', function(err, obj) {
console.log("Loaded from json:");
console.log(obj);
});
FAQs
Allows for very simple JSON file updating in one line
The npm package json-update receives a total of 804 weekly downloads. As such, json-update popularity was classified as not popular.
We found that json-update 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.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.