Lesson 7 / 24
JSON as the Standard
Why JSON won as the default wire format for REST APIs.
Text, typed, and everywhere
JSON is human-readable, maps cleanly onto objects/arrays/strings/numbers/booleans, and has a parser in every language. Unlike XML it carries little ceremony — no closing tags, no attributes-vs-elements debate.
Always set Content-Type
Return Content-Type: application/json; charset=utf-8 on every JSON response, even error bodies — clients shouldn't have to guess.
Numbers and dates need care
JSON has no native date type (use ISO 8601 strings like 2026-09-04T10:00:00Z) and its numbers can lose precision beyond ~2^53 — send very large IDs as strings.