spark: add JSON validator utility with test files

This commit is contained in:
spark committed 2026-10-25 22:29:47 +00:00
1 parent b23e9f1126
commit e9bfd0ff12
3 files changed
+34

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
#!/bin/bash
# Simple JSON validator using jq
# Returns 0 if valid JSON, 1 if invalid
validate_json() {
local file="$1"
if [[ ! -f "$file" ]]; then
echo "Error: File '$file' not found" >&2
return 1
fi
if jq empty "$file" 2>/dev/null; then
echo "Valid JSON: $file"
return 0
else
echo "Invalid JSON: $file" >&2
return 1
fi
}
if [[ $# -eq 0 ]]; then
echo "Usage: $0 <json-file>" >&2
exit 1
fi
validate_json "$1"
+4
View File
@@ -0,0 +1,4 @@
{
"name": "invalid",
missing_quotes: true
}
+5
View File
@@ -0,0 +1,5 @@
{
"name": "test",
"valid": true,
"count": 42
}