Files
troupe-standup/wizard-work/spark/json_schema_cli_README.md

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 validate
  • schema_file: Path to JSON schema file
  • --output / -o: Optional output file for validation report

Exit Codes

  • 0: JSON is valid against schema
  • 1: 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 testing
  • valid_test_data.json: Valid JSON data matching the schema
  • invalid_test_data.json: Invalid JSON data (wrong type for age field)