Pcornel
Automation · Data Formats › JSON

Validation

Cheat sheet · https://pcornel.dk/topic.php?topic=5823

Back to the Topic

Answer

Validate JSON first for syntax (jq . or python -m json.tool) and then for structure with JSON Schema, checking required fields, types and allowed values before automation uses the data.

Remember

  • Validate syntax first, then structure.
  • JSON Schema defines required fields and types.
  • Fail early on invalid data.

First checks

  • check-jsonschema --schemafile schema.json file.json — schema validation
  • python3 -c 'import jsonschema' — library
  • Schema version (draft 2020-12) — standard

Verify in this order

JSON document + schema → validator → pass/fail

Where it usually breaks

Client payload/auth → HTTP transport → endpoint validation/policy → request accepted → queued/job execution → target mutation → effective state → consumer workload.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=5823

Confirmation

Confirm action

Continue?