Arrays & Collections
Arrays in JSON represent ordered lists of values. They're essential for handling collections of data.
Array Basics
Arrays use square brackets [] and can contain any JSON values:
["apple", "banana", "cherry"]
[1, 2, 3, 4, 5]
[true, false, true]
[{"id": 1}, {"id": 2}]
Accessing Array Elements
Arrays are zero-indexed - the first element is at index 0:
Arrays of Objects
The most common pattern - arrays containing objects:
Nested Arrays
Arrays can contain other arrays:
Exercise: Access Array Element
Exercise: Get Array Length
Exercise: Access Last Element
Key Points
- Arrays are ordered, zero-indexed collections
- Use
[index]to access elements .lengthgives you the array size- Arrays commonly contain objects
- Nested arrays use chained brackets:
arr[0][1]

