json-fixer-browser
Version:
95 lines (70 loc) β’ 8.79 kB
Markdown
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
<!--lint disable list-item-indent -->
- [json-fixer](#json-fixer)
- [Usage](#usage)
- [Contributors β¨](#contributors-)
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
# json-fixer
[](https://nodei.co/npm/json-fixer/)
[](https://github.com/Berkmann18/json-fixer)
[](https://david-dm.org/berkmann18/json-fixer?type=dev)
[](https://david-dm.org/berkmann18/json-fixer)
[](https://github.com/Berkmann18/json-fixer/network/members)
[](https://github.com/Berkmann18/json-fixer/graphs/commit-activity)
[](https://github.com/Berkmann18/json-fixer/graphs/contributors)
[](https://github.com/Berkmann18/json-fixer/graphs/traffic)
[](https://travis-ci.org/Berkmann18/json-fixer)
[](https://codecov.io/github/Berkmann18/json-fixer?branch=master)
[](https://github.com/facebook/jest)
[](https://snyk.io/test/github/Berkmann18/json-fixer?targetFile=package.json)
[](https://github.com/Berkmann18/json-fixer/blob/master/LICENSE)
[](https://github.com/Berkmann18/json-fixer/issues)
[](http://commitizen.github.io/cz-cli/)
[](https://github.com/Berkmann18/json-fixer)
[](https://github.com/Berkmann18/json-fixer)
[](https://github.com/Berkmann18/json-fixer)
[](https://bettercodehub.com/results/Berkmann18/json-fixer)
[](https://app.codacy.com/manual/maxieberkmann/json-fixer?utm_source=github.com&utm_medium=referral&utm_content=Berkmann18/json-fixer&utm_campaign=Badge_Grade_Dashboard)
A JSON file fixer primarly focused to be used in a NodeJS file.
## Usage
- In NodeJS
```js
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))`
}
```
- In the CLI<br>
_Not supported yet_ (PR welcome).
## Contributors β¨
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
<tr>
<td align="center"><a href="http://maxcubing.wordpress.com"><img src="https://avatars0.githubusercontent.com/u/8260834?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Maximilian Berkmann</b></sub></a><br /><a href="https://github.com/Berkmann18/json-fixer/commits?author=Berkmann18" title="Code">π»</a> <a href="https://github.com/Berkmann18/json-fixer/commits?author=Berkmann18" title="Documentation">π</a> <a href="#ideas-Berkmann18" title="Ideas, Planning, & Feedback">π€</a> <a href="#maintenance-Berkmann18" title="Maintenance">π§</a> <a href="https://github.com/Berkmann18/json-fixer/commits?author=Berkmann18" title="Tests">β οΈ</a> <a href="#security-Berkmann18" title="Security">π‘οΈ</a></td>
<td align="center"><a href="http://semantic-release.org/"><img src="https://avatars1.githubusercontent.com/u/32174276?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Semantic Release Bot</b></sub></a><br /><a href="#platform-semantic-release-bot" title="Packaging/porting to new platform">π¦</a> <a href="https://github.com/Berkmann18/json-fixer/commits?author=semantic-release-bot" title="Documentation">π</a></td>
<td align="center"><a href="https://github.com/apps/all-contributors"><img src="https://avatars1.githubusercontent.com/u/649578?v=4?s=100" width="100px;" alt=""/><br /><sub><b>all-contributors[bot]</b></sub></a><br /><a href="https://github.com/Berkmann18/json-fixer/commits?author=all-contributors[bot]" title="Documentation">π</a></td>
<td align="center"><a href="https://github.com/Bkucera"><img src="https://avatars0.githubusercontent.com/u/14625260?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ben Kucera</b></sub></a><br /><a href="https://github.com/Berkmann18/json-fixer/commits?author=Bkucera" title="Code">π»</a></td>
<td align="center"><a href="https://github.com/SvetozarMateev"><img src="https://avatars3.githubusercontent.com/u/25162335?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Svetozar Mateev</b></sub></a><br /><a href="https://github.com/Berkmann18/json-fixer/issues?q=author%3ASvetozarMateev" title="Bug reports">π</a> <a href="https://github.com/Berkmann18/json-fixer/commits?author=SvetozarMateev" title="Code">π»</a></td>
<td align="center"><a href="https://andrepaulo.me"><img src="https://avatars1.githubusercontent.com/u/19685105?v=4?s=100" width="100px;" alt=""/><br /><sub><b>AndrΓ© Paulo</b></sub></a><br /><a href="https://github.com/Berkmann18/json-fixer/issues?q=author%3Aandre-paulo98" title="Bug reports">π</a></td>
<td align="center"><a href="https://www.linkedin.com/in/erkinmatkaziev/"><img src="https://avatars2.githubusercontent.com/u/22586805?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Erkin Matkaziev</b></sub></a><br /><a href="https://github.com/Berkmann18/json-fixer/issues?q=author%3AErkin97" title="Bug reports">π</a></td>
</tr>
<tr>
<td align="center"><a href="https://www.codacy.com/"><img src="https://avatars3.githubusercontent.com/u/23704769?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Codacy Badger</b></sub></a><br /><a href="#infra-codacy-badger" title="Infrastructure (Hosting, Build-Tools, etc)">π</a> <a href="https://github.com/Berkmann18/json-fixer/commits?author=codacy-badger" title="Documentation">π</a></td>
<td align="center"><a href="https://github.com/GiraffeKey"><img src="https://avatars2.githubusercontent.com/u/11844126?v=4?s=100" width="100px;" alt=""/><br /><sub><b>GiraffeKey</b></sub></a><br /><a href="https://github.com/Berkmann18/json-fixer/commits?author=GiraffeKey" title="Code">π»</a> <a href="https://github.com/Berkmann18/json-fixer/commits?author=GiraffeKey" title="Tests">β οΈ</a></td>
<td align="center"><a href="https://github.com/jonasmaertens"><img src="https://avatars3.githubusercontent.com/u/71458938?v=4?s=100" width="100px;" alt=""/><br /><sub><b>jonasmaertens</b></sub></a><br /><a href="https://github.com/Berkmann18/json-fixer/issues?q=author%3Ajonasmaertens" title="Bug reports">π</a></td>
<td align="center"><a href="https://geoxor.moe"><img src="https://avatars.githubusercontent.com/u/34042825?v=4?s=100" width="100px;" alt=""/><br /><sub><b>George Tsotsos</b></sub></a><br /><a href="https://github.com/Berkmann18/json-fixer/commits?author=Geoxor" title="Code">π»</a></td>
</tr>
</table>
<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
<!-- ALL-CONTRIBUTORS-LIST:END -->
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!