#!/bin/bash # jsonlint.sh - Validate and pretty-print JSON files # Usage: jsonlint.sh if [ -z "$1" ]; then echo "Usage: jsonlint.sh " >&2 exit 1 fi if [ ! -f "$1" ]; then echo "Error: File '$1' not found" >&2 exit 1 fi # Try to validate and pretty-print JSON using Python python3 -c " import sys import json try: with open('$1', 'r') as f: data = json.load(f) print(json.dumps(data, indent=2, sort_keys=True)) except json.JSONDecodeError as e: print(f'Invalid JSON: {e}', file=sys.stderr) sys.exit(1) except Exception as e: print(f'Error: {e}', file=sys.stderr) sys.exit(1) "