Lesson 3
JSON Data Types
Strings, numbers, booleans, null, and what JSON deliberately excludes.
JSON supports exactly six kinds of values. There are no dates, functions, or undefined—only what can be represented literally in text.
1. String
Text in double quotes. Escape sequences include \", \\, \n, \t, and \uXXXX for Unicode.
"message": "Hello, \"world\"!"
2. Number
JSON numbers are decimal; no NaN or Infinity. No leading plus on integers is required; fractions and exponents are allowed.
"count": 42,
"ratio": 0.75,
"large": 1.2e6
3. Boolean
Literals true or false (lowercase, unquoted).
"enabled": true
4. null
The literal null means “no value” or “empty” in many APIs—not the string "null".
"middleName": null
5. Object
Unordered collection of key–value pairs (order may be preserved by parsers but should not be relied on for semantics).
6. Array
Ordered list of values, indexed from zero in host languages after parsing.
What JSON does not include
| Not in JSON | Common workaround |
|---|---|
undefined | Omit the key or use null |
Date | ISO 8601 string: "2026-05-22T10:00:00Z" |
Map, Set | Arrays or objects |
| Comments | External docs or "_comment" fields (non-standard) |
| Single-quoted strings | Use double quotes |
Understanding these limits prevents confusion when mapping JSON to strongly typed application models.