Skip to main content
Back to Blog

Understanding JSON Data Structures: Objects, Arrays & Nesting

2026-04-20 7 min read

JSON represents data using four core building blocks: objects, arrays, strings, and numbers. Understanding how to combine these primitives into larger structures is essential for API design, database modeling, and configuration management.

The Four JSON Primitives

  • Object: An unordered collection of key-value pairs, enclosed in {}
  • Array: An ordered list of values, enclosed in []
  • String: Text enclosed in double quotes
  • Number: Integer or floating-point (no quotes)

Object vs Array: When to Use Each

Use Case Structure Example
Multiple properties of one entityObject{"name":"Alice", "age":30}
Collection of similar itemsArray[1, 2, 3]
Array of entitiesArray of objects[{"id":1,"name":"Alice"}]
Hierarchical dataNested objects{"user":{"profile":{"name":"Alice"}}}

Nesting Patterns

JSON shines at representing hierarchical relationships. A user object can contain an address object, which can contain coordinates. An API response can nest errors, metadata, and a data payload.

Nested structure example
{
  "user": {
    "id": 1,
    "name": "Alice",
    "address": {
      "street": "123 Main St",
      "city": "New York",
      "coordinates": {
        "lat": 40.7128,
        "lon": -74.0060
      }
    },
    "tags": ["engineer", "remote", "python"]
  }
}

Design tip

Avoid excessive nesting (more than 3-4 levels deep). Flat structures are easier to query and index in databases. Use database normalization principles when designing JSON schemas.

Visualize JSON structure

Paste your JSON to see the full tree view and navigate nested data.