# How I use JSONPath when a JSON response is too big to read

A beginner-friendly guide to JSONPath: selecting fields, walking arrays, filtering objects, and using JSON Path Explorer to understand large API responses.

- Date: 2026-09-27
- URL: https://ilham.dev/posts/how-to-use-jsonpath-to-find-data/
- Markdown: https://ilham.dev/posts/how-to-use-jsonpath-to-find-data/index.md
- Tags: json, jsonpath, api, tools
- Reading time: 3 min


Small JSON is easy to read. Large JSON is different. A real API response can contain
nested objects, arrays, metadata, and fields you do not care about.

JSONPath helps ask focused questions like:

> “Show me every email address in this response.”

or:

> “Find the order whose status is paid.”

The [JSON Path Explorer](/tools/json-path-explorer/) lets you paste JSON, try a
JSONPath expression, and see the matching values.

## The simple idea

JSONPath is like a path through JSON.

Given this JSON:

```json
{
  "user": {
    "name": "Ana",
    "email": "ana@example.com"
  }
}
```

This JSONPath:

```text
$.user.email
```

returns:

```text
ana@example.com
```

The `$` means “start at the root”. Then `.user.email` walks down into the object.

## Step 1: start at the root

Every JSONPath usually starts with:

```text
$
```

That means the whole document.

If you run only `$`, you are selecting everything.

## Step 2: select a normal object field

For object fields, use dots:

```text
$.user.name
```

Given:

```json
{
  "user": {
    "name": "Ana"
  }
}
```

Result:

```text
Ana
```

This is the easiest case.

## Step 3: select an array item by index

Arrays use numbers starting from zero.

Given:

```json
{
  "users": [
    { "name": "Ana" },
    { "name": "Budi" }
  ]
}
```

This selects the first user:

```text
$.users[0]
```

This selects the second user's name:

```text
$.users[1].name
```

Result:

```text
Budi
```

## Step 4: select every item in an array

Use `*` to mean every item:

```text
$.users[*].name
```

Given:

```json
{
  "users": [
    { "name": "Ana" },
    { "name": "Budi" }
  ]
}
```

Result:

```text
Ana
Budi
```

This is one of the most useful JSONPath patterns.

## Step 5: find a field anywhere

Sometimes you do not know where a field is nested. Recursive search can help:

```text
$..email
```

Plain meaning:

> Find every field named `email` anywhere in the document.

This is useful for exploring an unfamiliar response.

Be careful with very large JSON documents. Recursive searches can return many
matches.

## Step 6: filter array items

Filters let you select objects that match a condition.

Given:

```json
{
  "orders": [
    { "id": 1, "status": "paid" },
    { "id": 2, "status": "pending" }
  ]
}
```

This selects paid orders:

```text
$.orders[?(@.status == "paid")]
```

Plain meaning:

> Inside `orders`, keep items where the item's `status` is `paid`.

The `@` means “the current item being checked”.

To get only the id:

```text
$.orders[?(@.status == "paid")].id
```

Result:

```text
1
```

## Step 7: use the explorer instead of guessing

Open [JSON Path Explorer](/tools/json-path-explorer/) and paste your JSON.

Then try simple expressions first:

```text
$
$.users
$.users[*]
$.users[*].email
```

Build the path one step at a time. Do not start with a complicated filter.

The explorer is useful because it shows both the matched value and its path. That
helps you learn the structure of the JSON.

## Step 8: click through the tree

When the JSON shape is unfamiliar, I start by expanding the tree view.

I look for:

- arrays of records;
- repeated field names;
- ids;
- status fields;
- timestamps;
- nested `data` objects;
- pagination metadata.

Then I write the JSONPath after I understand where the value lives.

## Common JSONPath patterns

Select all ids:

```text
$..id
```

Select names from a users array:

```text
$.users[*].name
```

Select the first item:

```text
$.items[0]
```

Select paid orders:

```text
$.orders[?(@.status == "paid")]
```

Select email fields anywhere:

```text
$..email
```

## My JSONPath checklist

When writing a JSONPath expression, I check:

1. Does the JSON start with an object or an array?
2. What is the root path?
3. Am I selecting one item by index or all items with `*`?
4. Do I know the exact field location, or should I explore with `$..field`?
5. If filtering, what does one array item look like?
6. Can I build the expression one step at a time?

JSONPath is not about memorising every feature. It is about turning a large response
into a small answer.
