Array
RFC 8259 §5[ value, value, ... ]
A JSON array is an ordered sequence of zero or more values enclosed in square brackets, separated by commas. Array elements can be any JSON value type including other arrays and objects. Element order is guaranteed and significant. Duplicate values are allowed.
Description
JSON arrays use zero-based index ordering that is preserved in all compliant implementations. This is guaranteed by RFC 8259 – unlike object keys, array element order is significant and must be maintained.
Arrays can contain mixed types: [1, "two", true, null, {"key": "value"}, [1, 2]]. There is no typed array concept in core JSON.
Practical API design note: avoid large flat arrays in paginated APIs. Return arrays inside an envelope object so you can add pagination metadata without a breaking change: {"data": [...], "total": 42, "cursor": "xyz"} instead of returning a bare array.
Examples
| Label | Value |
|---|---|
| Empty | [] |
| Integers | [1, 2, 3] |
| Mixed types | [1, "two", true, null] |
| Nested | [[1, 2], [3, 4]] |
| Objects | [{"id": 1}, {"id": 2}] |
Common Gotchas
Trailing comma not allowed: [1, 2, 3,] is invalid JSON
Element order is guaranteed – do not sort arrays when preserving order matters
No typed arrays – [1, "two"] is valid JSON even if your schema doesn't intend it
Avoid bare top-level arrays in APIs – wrap in an object for future extensibility
Very large arrays can cause OOM in streaming parsers if not streamed carefully