53 lines
2.0 KiB
Markdown
53 lines
2.0 KiB
Markdown
# 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 correctly
|
|
- `error`: error message with line/column info for invalid files
|
|
- `type`: 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:
|
|
1. Validates proper JSON files and outputs structured results
|
|
2. Detects invalid JSON with accurate line/column locations
|
|
3. Exits with code 0 for valid, 1 for invalid
|
|
4. Handles files of various sizes |