JSON & YAML Data
Cheat sheet · https://pcornel.dk/topic.php?topic=93
Answer
JSON and YAML represent structured data as nested objects (key/value maps) and lists. JSON is used by REST APIs; YAML, which is easier to read, is used for Ansible playbooks, inventories and configuration templates.
Remember
JSON: double quotes, no comments, no trailing commas. YAML: indentation with spaces (never tabs) defines structure; - starts a list item; quote values like yes, no, on and leading zeros, or YAML turns them into booleans or numbers. Both map directly to Python dicts and lists.
First checks
python3 -m json.tool file.json/jq . file.json— JSON valid and pretty-printed.python3 -c 'import yaml,sys; print(yaml.safe_load(open(sys.argv[1])))' file.yml— YAML parses to the expected structure.yamllint file.yml— indentation and style errors.jq '.items[].name' file.json— extract fields to check the structure.
Verify in this order
data written → parser accepts it → structure (objects, lists, types) matches the schema → tool or API consumes it → result as expected
Where it usually breaks
physical/link dependency → local object state → peer/control state → policy → forwarding/adjacency → end-to-end result
Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=93