https://github.com/anyone-developer/anyone-validate-json
This action helps you to validate JSON syntax in a specified directory. And write back with formatted content. read file recursively with specified file extensions.
https://github.com/anyone-developer/anyone-validate-json
anyone-developer anyone-validate-json github-actions javascript nodejs typescript
Last synced: about 1 year ago
JSON representation
This action helps you to validate JSON syntax in a specified directory. And write back with formatted content. read file recursively with specified file extensions.
- Host: GitHub
- URL: https://github.com/anyone-developer/anyone-validate-json
- Owner: anyone-developer
- License: gpl-3.0
- Created: 2020-11-09T05:22:55.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2023-01-25T21:03:05.000Z (over 3 years ago)
- Last Synced: 2025-04-21T23:39:50.427Z (about 1 year ago)
- Topics: anyone-developer, anyone-validate-json, github-actions, javascript, nodejs, typescript
- Language: TypeScript
- Homepage:
- Size: 1.29 MB
- Stars: 3
- Watchers: 1
- Forks: 2
- Open Issues: 21
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README
# anyone-validate-json



[](https://app.fossa.com/projects/custom%2B21065%2Fgit%40github.com%3Aanyone-developer%2Fanyone-validate-json.git?ref=badge_small)
[](https://github.com/anyone-developer/anyone-validate-json/network/updates)


[](https://travis-ci.org/anyone-developer/anyone-validate-json)
[](https://github.com/xojs/xo)
[](https://lgtm.com/projects/g/anyone-developer/anyone-validate-json/alerts/)
[](https://lgtm.com/projects/g/anyone-developer/anyone-validate-json/context:javascript)
[](https://deepscan.io/dashboard#view=project&tid=11532&pid=14440&bid=269275)
[](https://gitpod.io/#https://github.com/anyone-developer/anyone-validate-json)
This action helps you to validate JSON syntax in a specified directory. And write back with formatted content. read file recursively with specified file extensions.
*If you like my module, please buy me a coffee.*
*More and more tiny and useful GitHub action modules are on the way. Please donate to me. I accept a part-time job contract. if you need, please contact me: zhang_nan_163@163.com*
## Inputs
### `read-path`
**Required** the path that you assign to read.
### `ignore-files`
the files you want to ignore. split with a comma.
### `ignore-directories`
the directories you want to ignore. split with a comma.
### `file-extension`
file extension that you want to read. such as "config" or "xml". split with comma.
## Outputs
### `output`
the output of execution.
## Other way usages
### `From NPM for programmatic use`
- create a 'demo' folder
- **npm init** to create your nodejs package
- copy 'sample_folder' to demo
- **npm install anyone-validate-json** to install module
- create 'index.js' and copy code below:
```typescript
import avj from '@anyone-developer/anyone-validate-json';
avj(['.config', 'json'], ['README.md'], ['c'], 'sample_folder').then(result => {
const succeed = result.filter(i => i?.formatted);
const failed = result.filter(i => i?.err);
if (succeed?.length > 0) {
console.info(`[${chalk.greenBright.bgYellowBright.bold('Succeed')}]`);
succeed.forEach(v => {
console.info(chalk.greenBright(`path: ${v.path}`));
});
}
if (succeed?.length > 0 && failed?.length > 0) {
console.log(`---------😀${chalk.gray.bold('Happy Delimiter')}😀---------`);
}
if (failed?.length > 0) {
console.error(`[${chalk.redBright.bgRedBright.bold('Failed')}]`);
failed.forEach(v => {
console.error(chalk.greenBright(`path: ${v.path} msg: ${v.err?.message}`));
});
}
}).catch(error => console.error(error));
```
- **node index.js** to run it
### `From NPM for using as a command-line app`
- **npm install -g anyone-validate-json** to install gobally
- **anyone-validate-json -r 'sample_folder' -f '.config,.json' -I ".git" -i "README.md"** to use your bash to execute it.
## Example usage
```yml
uses: anyone-developer/anyone-validate-json@main
with:
file-extension: '.config,.json'
ignore-files: 'README.md'
ignore-directories: '.git'
read-path: 'sample_folder'
```
## Fossa Report
[](https://app.fossa.com/projects/custom%2B21065%2Fgit%40github.com%3Aanyone-developer%2Fanyone-validate-json.git?ref=badge_large)
## Donation
PalPal: https://paypal.me/nzhang4

