TExcelTAD
Home › JSON › JSON Data Types

JSON Data Types

Every JSON value belongs to exactly one of six types. Four are simple values and two are containers.

Type Kind Example
string simple "Hello"
number simple 3.14
boolean simple true
null simple null
object container {"x": 1}
array container [1, 2]

Strings

A string is a sequence of Unicode characters inside double quotes. Some characters must be escaped with a backslash:

Escape Meaning
\" double quote
\\ backslash
\/ forward slash (optional)
\n new line
\t tab
\r \b \f carriage return, backspace, form feed
\u00e9 any character by its 4-digit hex code (é)
json · try it yourself
{
  "quote": "She said \"hi\"",
  "path": "C:\\Users\\an",
  "lines": "first\nsecond",
  "accent": "caf\u00e9"
}
Valid JSON: object with 4 keys
{
  "quote": "She said \"hi\"",
  "path": "C:\\Users\\an",
  "lines": "first\nsecond",
  "accent": "café"
}

Notice that \u00e9 came back as the actual é character — both spellings mean the same string. A raw line break or tab typed directly inside a string is not allowed; you must use \n or \t.

Numbers

JSON has a single number type for integers and decimals. It is written in base 10 and may have a minus sign, a fraction and an exponent.

Valid Invalid Why invalid
0, -7, 42 +7 no leading plus
3.14 .5, 5. digits needed on both sides of .
1e6, 2.5E-3 007 no leading zeros
-0.001 0xFF no hexadecimal
NaN, Infinity not part of JSON
json · try it yourself
[0, -7, 3.14, 1e6, 2.5E-3, 1.50]
Valid JSON: array with 6 items
[
  0,
  -7,
  3.14,
  1000000,
  0.0025,
  1.5
]

The output shows that 1e6 and 1.50 are just different spellings of the numbers 1000000 and 1.5.

Booleans

Exactly two values, always lowercase: true and false. True, TRUE and "true" (a string!) are not booleans.

null

null means "no value" or "unknown". It is lowercase. JSON has no undefined.

json · try it yourself
{"middleName": null, "nickname": undefined}
Invalid JSON: Unexpected token 'u', ..."ickname": undefined}" is not valid JSON

Objects and arrays

Objects are unordered collections of name/value pairs inside { }; arrays are ordered lists of values inside [ ]. They can contain any type, including each other. They each get their own lesson next.

What JSON does NOT have

Missing Common workaround
Dates ISO 8601 string: "2025-03-14T09:30:00Z"
undefined Leave the key out, or use null
Functions Not representable — send data, not code
Binary data Base64-encoded string
Comments A "_comment" key, or a format like JSONC
Integers bigger than 2^53 Send them as strings

Seeing the types from JavaScript

When JavaScript parses JSON, each type becomes a familiar JavaScript value:

js · try it yourself
const doc = JSON.parse('{"s": "text", "n": 12.5, "b": true, "z": null, "o": {}, "a": []}');

for (const [key, value] of Object.entries(doc)) {
  const kind = value === null ? "null" : Array.isArray(value) ? "array" : typeof value;
  console.log(key, "->", kind);
}
s -> string
n -> number
b -> boolean
z -> null
o -> object
a -> array

Tip: typeof null is "object" in JavaScript and typeof [] is also "object", which is why the code above checks for null and Array.isArray() first.

Test yourself

Which of these is NOT a JSON data type?

  1. boolean
  2. null
  3. date
  4. array

Which number is valid JSON?

  1. 0x1F
  2. -0.5
  3. .5
  4. 012

How do you write a double quote inside a JSON string?

  1. ''
  2. \"
  3. ""
  4. "