spark: add json-check.py - validate and pretty-print JSON files or stdin

This commit is contained in:
spark committed 2026-10-27 00:38:41 +00:00
1 parent b14d2e42cb
commit 233007b0c5
1 file changed
+17
+17
View File
@@ -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())