Pcornel
Automation · APIs

JSON

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

Back to the Topic

Answer

JSON representation semantics for API payloads, including types, null, arrays/objects, numeric precision and schema validation.

Remember

  • JSON parsed ≠ schema valid; syntax allows structures the API may reject or reinterpret.
  • JSON number ≠ exact arbitrary precision; large integers and decimals can lose precision in clients.
  • null ≠ absent; APIs often assign different update/default semantics to each.
  • Object key order ≠ semantic order; consumers must not depend on serialization order.

First checks

  • curl -sS <url> | jq . — parse JSON
  • Content-Type: application/json check — before parsing
  • jq -e '.error' response.json — detect error objects

Verify in this order

response body → JSON parser → objects

Where it usually breaks

Successful JSON parsing proves only syntactic validity; type coercion, schema and business semantics remain unproven.

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

JSON API boundary map

BoundaryHealthy evidenceSuspicious evidence
Caller / requestEnvironment/version, identity and exact request contract are attributableHidden defaults, wrong endpoint/version, leaked or mismatched credentials
Server / responseStatus, headers, structured body and request ID are interpreted togetherStatus-only handling, ignored error body, ambiguous async result or unsafe retry
State / proofWrite result is reconciled with resource read-back or acceptance testResponse success treated as final target success without verification
TroubleshootingFirst failed boundary is preserved, changed minimally and retestedBlind retries, credential rotation, replay or payload edits before evidence is captured

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

Confirmation

Confirm action

Continue?