$ npm install json-fixer
A JSON file fixer primarly focused to be used in a NodeJS file.
const jsonFix = require('json-fixer')
const fs = require('fs')
// Get the (potentially malformed) JSON data ready
const jsonContent = fs.readFileSync('config.json', 'utf-8')
const {data, changed} = jsonFix(jsonContent) // Lint (and fix) it
if (changed) {
// Do something with `data` which is the fixed JSON parsed data from `jsonContent`
// e.g. `fs.writeFileSync(configPath, JSON.stringify(data, null, 2))`
}
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!
© 2010 - cnpmjs.org x YWFE | Home | YWFE