
Security News
AI Agent Lands PRs in Major OSS Projects, Targets Maintainers via Cold Outreach
An AI agent is merging PRs into major OSS projects and cold-emailing maintainers to drum up more work.
jsonfile-commentless
Advanced tools
Easily read/write JSON files.
Writing JSON.stringify() and then fs.writeFile() and JSON.parse() with fs.readFile() enclosed in try/catch blocks became annoying. Then not being able to strip comments with the standard jsonfile package also became annoying.
npm install --save jsonfile-commentless
options (object, default undefined): Pass in any fs.readFile options or set reviver for a JSON reviver.
throws (boolean, default: true). If JSON.parse throws an error, pass this error to the callback.
If false, returns null for the object.var jsonfile = require('jsonfile-commentless')
var file = '/tmp/data.json'
jsonfile.readFile(file, function(err, obj) {
console.dir(obj)
})
options (object, default undefined): Pass in any fs.readFileSync options or set reviver for a JSON reviver.
throws (boolean, default: true). If an error is encountered reading or parsing the file, throw the error. If false, returns null for the object.var jsonfile = require('jsonfile-commentless')
var file = '/tmp/data.json'
console.dir(jsonfile.readFileSync(file))
options: Pass in any fs.writeFile options or set replacer for a JSON replacer. Can also pass in spaces and override EOL string.
var jsonfile = require('jsonfile-commentless')
var file = '/tmp/data.json'
var obj = {name: 'JP'}
jsonfile.writeFile(file, obj, function (err) {
console.error(err)
})
formatting with spaces:
var jsonfile = require('jsonfile-commentless')
var file = '/tmp/data.json'
var obj = {name: 'JP'}
jsonfile.writeFile(file, obj, {spaces: 2}, function(err) {
console.error(err)
})
overriding EOL:
var jsonfile = require('jsonfile-commentless')
var file = '/tmp/data.json'
var obj = {name: 'JP'}
jsonfile.writeFile(file, obj, {spaces: 2, EOL: '\r\n'}, function(err) {
console.error(err)
})
appending to an existing JSON file:
You can use fs.writeFile option {flag: 'a'} to achieve this.
var jsonfile = require('jsonfile-commentless')
var file = '/tmp/mayAlreadyExistedData.json'
var obj = {name: 'JP'}
jsonfile.writeFile(file, obj, {flag: 'a'}, function (err) {
console.error(err)
})
options: Pass in any fs.writeFileSync options or set replacer for a JSON replacer. Can also pass in spaces and override EOL string.
var jsonfile = require('jsonfile-commentless')
var file = '/tmp/data.json'
var obj = {name: 'JP'}
jsonfile.writeFileSync(file, obj)
formatting with spaces:
var jsonfile = require('jsonfile-commentless')
var file = '/tmp/data.json'
var obj = {name: 'JP'}
jsonfile.writeFileSync(file, obj, {spaces: 2})
overriding EOL:
var jsonfile = require('jsonfile-commentless')
var file = '/tmp/data.json'
var obj = {name: 'JP'}
jsonfile.writeFileSync(file, obj, {spaces: 2, EOL: '\r\n'})
appending to an existing JSON file:
You can use fs.writeFileSync option {flag: 'a'} to achieve this.
var jsonfile = require('jsonfile-commentless')
var file = '/tmp/mayAlreadyExistedData.json'
var obj = {name: 'JP'}
jsonfile.writeFileSync(file, obj, {flag: 'a'})
(MIT License)
Original Work : https://github.com/jprichardson/node-jsonfile
Copyright 2012-2016, JP Richardson jprichardson@gmail.com
Modified Work : https://github.com/z3dtech/node-jsonfile
Copyright 2017, z3dtech z@z3d.tech
FAQs
Easily read/write JSON files. Also strips comments.
The npm package jsonfile-commentless receives a total of 3 weekly downloads. As such, jsonfile-commentless popularity was classified as not popular.
We found that jsonfile-commentless demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers 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
An AI agent is merging PRs into major OSS projects and cold-emailing maintainers to drum up more work.

Research
/Security News
Chrome extension CL Suite by @CLMasters neutralizes 2FA for Facebook and Meta Business accounts while exfiltrating Business Manager contact and analytics data.

Security News
After Matplotlib rejected an AI-written PR, the agent fired back with a blog post, igniting debate over AI contributions and maintainer burden.