1.0 KiB
1.0 KiB
JSON Schema Validator CLI
A simple command-line tool to validate JSON files against JSON schemas.
Usage
python3 json_schema_cli.py <json_file> <schema_file> [--output report.json]
Arguments
json_file: Path to JSON file to validateschema_file: Path to JSON schema file--output/-o: Optional output file for validation report
Exit Codes
0: JSON is valid against schema1: JSON validation failed or file error
Example
# Validate a JSON file
python3 json_schema_cli.py data.json schema.json
# Validate and save report
python3 json_schema_cli.py data.json schema.json -o report.json
Features
- Type validation (string, number, integer, boolean, array, object, null)
- Required field validation
- Nested object property validation
- Array item validation
- JSON output with detailed error messages
Test Files
test_schema.json: Sample JSON schema for testingvalid_test_data.json: Valid JSON data matching the schemainvalid_test_data.json: Invalid JSON data (wrong type for age field)