Lesson 3 — Fundamentals

Data Types in JSON

JSON supports exactly six data types: strings, numbers, booleans, null, objects, and arrays — a deliberately small set that keeps the format simple and universal.

The Six Types

Every value in a JSON document is one of these six types, and nothing else — there's no separate "integer" vs "float" type, no dates, and no undefined.

JSON — All six data types
{
  "aString": "Hello",
  "aNumber": 42.5,
  "aBoolean": true,
  "aNull": null,
  "anObject": { "nested": "value" },
  "anArray": [1, 2, 3]
}

Common Mistakes

  • Trying to represent a date as a native JSON type — dates must be represented as strings (commonly ISO 8601 format) since JSON has no date type.
  • Confusing JavaScript's undefined with JSON's null — JSON has no concept of undefined at all.
  • Assuming JSON distinguishes integers from decimals as separate types — JSON has one unified 'number' type.
  • Wrapping a boolean or number value in quotes, accidentally turning it into a string.

Professional Tip

Because JSON has no dedicated date type, the widely adopted convention is to represent dates as ISO 8601 strings, like "2026-09-12T10:30:00Z", which most languages can parse reliably.

Your Turn

Write a JSON object representing a product with a string name, a numeric price, a boolean inStock flag, a null discontinuedDate, and a nested object for its dimensions.

Mini Quiz

How many distinct data types does the JSON specification define?