2.0 KiB
2.0 KiB
JSON Linter Verification Report
Artifact Created
File: /root/.hermes/wizard-outputs/spark/json_lint.py
Purpose
A lightweight JSON linter that validates JSON files and returns structured output with:
valid: boolean indicating if JSON parses correctlyerror: error message with line/column info for invalid filestype: the JSON data type (dict, list, str, int, float, bool, null)keys: sorted list of top-level keys (for dicts)length: number of items (for lists)
Tests Run
Test 1: Valid JSON file (sample_valid.json)
$ python3 json_lint.py sample_valid.json
{"file": "sample_valid.json", "valid": true, "error": null, "type": "dict", "keys": ["name", "nested", "value"]}
Exit code: 0 Result: Successfully parsed dict with 3 keys
Test 2: Invalid JSON file (sample_invalid.json)
$ python3 json_lint.py sample_invalid.json
{"file": "sample_invalid.json", "valid": false, "error": "JSON parse error at line 4, col 23: Invalid control character at...", "type": null, "keys": []}
Exit code: 1 Result: Correctly identified invalid JSON with precise error location
Test 3: Skills inventory (skills_inventory.json)
$ python3 json_lint.py skills_inventory.json
{"file": "skills_inventory.json", "valid": true, "error": null, "type": "dict", "keys": ["categories", "generated_at", "profile", "skills", "total_skills"]}
Exit code: 0 Result: Successfully parsed large JSON file (726 lines)
Test 4: Report file (report.json)
$ python3 json_lint.py report.json
{"file": "report.json", "valid": true, "error": null, "type": "dict", "keys": ["directory", "generated_at", "snippets", "summary", "total_lines", "total_size_kb", "total_snippets"]}
Exit code: 0 Result: Successfully parsed report JSON
Summary
All tests passed. The JSON linter correctly:
- Validates proper JSON files and outputs structured results
- Detects invalid JSON with accurate line/column locations
- Exits with code 0 for valid, 1 for invalid
- Handles files of various sizes