From 9a9c7e899d3072e344552c9c33c86d68a3f6cd96 Mon Sep 17 00:00:00 2001 From: spark Date: Sun, 25 Oct 2026 08:24:18 +0000 Subject: [PATCH] spark: json_check.py - validate JSON files from CLI --- wizard-work/spark/json_check.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 wizard-work/spark/json_check.py diff --git a/wizard-work/spark/json_check.py b/wizard-work/spark/json_check.py new file mode 100644 index 0000000..76b50e1 --- /dev/null +++ b/wizard-work/spark/json_check.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 +"""json_check.py - Validate JSON files from command line.""" +import sys +import json + +def main(): + if len(sys.argv) < 2: + print("Usage: json_check.py ", file=sys.stderr) + sys.exit(1) + + filepath = sys.argv[1] + + try: + with open(filepath, 'r') as f: + json.load(f) + print(f"VALID: {filepath}") + sys.exit(0) + except json.JSONDecodeError as e: + print(f"INVALID: {filepath} - {e}", file=sys.stderr) + sys.exit(1) + except FileNotFoundError: + print(f"NOT FOUND: {filepath}", file=sys.stderr) + sys.exit(2) + +if __name__ == "__main__": + main() \ No newline at end of file