developer•2026-10-17•4 min read

JSON Objects, Arrays, and Value Types Explained with Real Examples

Master the 6 official JSON data types under RFC 8259: objects, arrays, strings, numbers, booleans, and null, and understand why undefined and functions are forbidden.

JSON Objects, Arrays, and Value Types Explained with Real Examples
Dedicated Browser Utility

JSON Tools

Format, validate, view in a collapsible interactive tree, and visually edit JSON with draft safety.

Open Tool Now
Grid explaining the six permitted JSON value types: object, array, string, number, boolean, and null
Comprehensive overview of the six RFC 8259 JSON value types and their syntax requirements.

Despite powering almost the entire internet's API ecosystem, JSON is remarkably minimalist. Defined formally by RFC 8259, the JSON grammar permits exactly six data types.

While modern programming languages like TypeScript, Python, and Rust feature hundreds of rich types (enums, tuples, sets, maps, decimals, and dates), transferring data across the wire requires mapping everything into these six universal primitives.

In this guide, you will explore how each JSON data type works, inspect real-world examples, avoid common type conversion pitfalls, and learn how to inspect types visually.


The 6 Universal JSON Data Types

Diagram contrasting the 6 permitted JSON types against common forbidden JavaScript types
Contrasting permitted RFC 8259 JSON types with forbidden types like undefined, functions, and NaN.

1. Object (`{}`)

An object is an unordered collection of zero or more key-value pairs wrapped in curly braces.

  • Rule: Every key must be a string enclosed in double quotes (").
  • Rule: Keys must be separated from values by a colon (:).
  • Rule: Key-value pairs must be separated by commas (,).
{
  "user_id": 1092,
  "username": "alex_codes",
  "verified": true
}

2. Array (`[]`)

An array is an ordered sequence of zero or more values enclosed in square brackets.

  • Rule: Elements are zero-indexed ([0], [1], [2]).
  • Rule: Arrays can store mixed types, including nested objects and other arrays.
[
  "first",
  42,
  false,
  null,
  { "nested": "object" }
]

3. String (`""`)

A string is a sequence of zero or more Unicode characters wrapped in double quotes (").

  • Rule: Single quotes (') are strictly forbidden.
  • Rule: Special characters must be escaped with a backslash (e.g., \", \\, \n, \t).
{
  "title": "Senior Frontend Engineer",
  "quote": "Code is poetry, \"clean\" code is art.",
  "unicode_flag": "\u2600 Sun"
}

4. Number

JSON numbers can be integers, fractions, or exponential scientific notations.

  • Rule: Numbers cannot have leading zeros (e.g., 052 is illegal; write 52).
  • Rule: NaN, Infinity, and -Infinity are strictly forbidden.
  • Rule: Hexadecimal literals (0x1F) and octals are illegal.
{
  "integer": 42,
  "negative": -18,
  "decimal": 3.14159,
  "scientific": 1.25e+4
}

5. Boolean (`true` / `false`)

JSON booleans represent binary truth values.

  • Rule: Must be lowercase literal true or false.
  • Rule: Capitalized True, False, or string "true" are not boolean values.
{
  "is_admin": true,
  "email_verified": false
}

6. Null (`null`)

null represents an intentionally empty or non-existent value.

  • Rule: Must be lowercase literal null.
  • Rule: Distinct from 0, false, or an empty string "".
{
  "middle_name": null,
  "deleted_at": null
}

4 Things Developers Try to Put in JSON (That Fail!)

If you write full-stack JavaScript or Python, it is tempting to pass language features directly to JSON. Here is why they break:

Invalid TypeWhy It FailsSafe Alternative
undefinedOmitted by RFC 8259; triggers parse crashes.Use null or omit the key entirely.
Functions () => {}Executable logic is strictly forbidden in data formats.Send identifiers or parameters instead.
Date objectsNo native date type exists in JSON.Serialize to ISO 8601 string: "2026-10-17T02:00:00Z".
NaN / InfinityJSON requires finite numeric values.Use null or numerical flags.

Inspecting Types Visually with UtilityKit

When inspecting a large JSON file, distinguishing between string numbers ("42" vs 42) or string booleans ("true" vs true) in raw text is tedious.

UtilityKit's JSON Tools highlights types automatically:

  1. Tree Viewer Mode: Badges each node as STR, NUM, BOOL, NULL, OBJ, or ARR with dedicated color accents.
  2. Visual Editor Mode: Provides a type selector dropdown next to every key, letting you convert types safely without breaking quotes or brackets.
Tags:#json value types#json objects and arrays#json primitives#rfc 8259#developer tools

Frequently Asked Questions

Quick answers to common questions for users and search assistants

Can a valid JSON file contain only a string or a number?
Yes. Under RFC 8259, any of the six valid JSON types can exist as the root document. A file containing just '\"Hello World\"' or '42' is 100% legal JSON, even though older obsolete specifications (like RFC 4627) required an outer object or array.
What happens to undefined or functions when serializing to JSON?
JSON does not support undefined, functions, or symbol types. In JavaScript, JSON.stringify() silently strips object properties with undefined values, converts array elements with undefined to null, and omits functions completely.
How does JSON represent dates and timestamps?
JSON has no native Date data type. By convention, dates are represented either as ISO 8601 strings (e.g., '\"2026-10-17T02:00:00Z\"') or as Unix epoch timestamps in milliseconds (e.g., 1792195200000).

Related Utilities Mentioned in This Guide

Browse directory

Continue Reading

Advertisement