Pcornel
Automation · Data Formats

JSON

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

Back to the Topic

Answer

JSON is the standard data format for APIs and many tools: objects of key-value pairs, arrays, strings, numbers, booleans and null. Parse it with jq, ConvertFrom-Json or json.loads.

Remember

  • JSON has objects, arrays, strings, numbers, booleans and null.
  • JSON has no comments.
  • Parse with jq, ConvertFrom-Json or json.loads.

First checks

  • jq . file.json — validate
  • jq '.items[] | .name' file.json — extract
  • python3 -m json.tool file.json — pretty print

Commands

jq . <file.json>
Read current JSON state for a bounded verification step.

Verify in this order

JSON text → parser → data structure

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=5818

Confirmation

Confirm action

Continue?