Automation · Python Automation
JSON
Cheat sheet · https://pcornel.dk/topic.php?topic=5267
Answer
Python handles JSON with the json module: json.load and json.loads to parse, json.dump and json.dumps with indent to write, mapping objects to dicts and arrays to lists.
Remember
- json.load/loads parse; json.dump/dumps write.
- Objects become dicts, arrays become lists.
- indent makes output readable.
First checks
python3 -m json.tool file.json— validate/pretty printpython3 -c 'import json;json.load(open("f.json"))'— parse- Schema validation (jsonschema) — structure
Verify in this order
JSON text → json.loads → objects → validation
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=5267