Automation · Data Formats › JSON
Parsing
Cheat sheet · https://pcornel.dk/topic.php?topic=5822
Answer
Parse JSON with built-in tools — jq on the command line, ConvertFrom-Json in PowerShell, json.loads in Python — and handle errors when the input is not valid JSON.
Remember
- Use jq, ConvertFrom-Json or json.loads.
- Catch parse errors on invalid input.
- PowerShell ConvertTo-Json needs -Depth for nested data.
First checks
jq -e . file.json >/dev/null && echo valid— parse checkpython3 -c 'import json;json.load(open("f.json"))'— Python parseConvertFrom-Json (PowerShell)— parse
Verify in this order
text → JSON parser → objects or error
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=5822