https://github.com/atomicptr/json-linter
Lint your JSON files!
https://github.com/atomicptr/json-linter
Last synced: 7 months ago
JSON representation
Lint your JSON files!
- Host: GitHub
- URL: https://github.com/atomicptr/json-linter
- Owner: atomicptr
- License: gpl-3.0
- Created: 2022-12-01T15:18:57.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2022-12-14T09:58:19.000Z (about 3 years ago)
- Last Synced: 2024-11-10T04:15:50.186Z (about 1 year ago)
- Language: Python
- Size: 41 KB
- Stars: 6
- Watchers: 2
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# json-linter
Lint your JSON files!
## Features
* Check if keys are sorted alphabetically...
* Check if your keys are either in camelCase, snake\_case or kebab-case...
* ...and automatically fix (some) of these issues!
## Install
You need to have Python 3.10+ installed.
```bash
$ pip install json-linter
```
## Usage
```bash
# Lint a single file...
$ json-linter my-file.json
# Lint multiple files...
$ json-linter a.json b.json
# Lint all files in a directory
$ json-linter files
# Lint all files in a directory recursively
$ json-linter files --recursive
# Lint all files in a directory recursively with .config and .cfg ending
$ json-linter files -r --extensions cfg config
# Fix files (will overwrite the file with a fixed version and then lint)
$ json-linter my-file.json --fix
# Overwrite configuration values
$ json-linter my-file.json --config-set naming_style=KEBAB_CASE indent=2
# Return results as json
$ json-linter my-file.json --json
```
### Use as a package
```python
from pathlib import Path
from json_linter import lint_file
results = lint_file(Path("./my-file.json"))
for result in results:
if not result.was_successful:
print(result.path, "failed!")
```
## License
GNU General Public License v3
