From 233007b0c50d32acd796cbfd1237a41f97284f0b Mon Sep 17 00:00:00 2001 From: spark Date: Tue, 27 Oct 2026 00:38:41 +0000 Subject: [PATCH] spark: add json-check.py - validate and pretty-print JSON files or stdin --- wizard-work/spark/json-check.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100755 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 100755 index 0000000..d78b82d --- /dev/null +++ b/wizard-work/spark/json-check.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python3 +"""json-check: Validate and pretty-print JSON files or stdin.""" +import json +import sys + +def main(): + if len(sys.argv) > 1: + with open(sys.argv[1], 'r') as f: + data = json.load(f) + else: + data = json.load(sys.stdin) + + print(json.dumps(data, indent=2, sort_keys=True)) + return 0 + +if __name__ == '__main__': + sys.exit(main()) \ No newline at end of file