An API response lands in your editor: a few hundred lines of nested objects and arrays. Somewhere inside it is one value you actually need, maybe the title of the first item, maybe a status field three levels down. Scrolling through the raw JSON to find it works, but it is slow, and it gives you nothing you can reuse the next time the response changes shape slightly.

A JSONPath expression is the reusable version of that search. It is a written path from the root of the document to the field, and once it works you can run it against the next response unchanged. This guide extracts one field with the free JSONPath Tester on Ovatly, building the path one level at a time so mistakes are easy to find.

Contents

  • Quick answer
  • Why build the path one level at a time
  • How to extract one field, step by step
  • Worked example: one title out of a shop response
  • Reading the result: one match, many matches, zero matches
  • Limitations and honest tradeoffs
  • Common mistakes
  • FAQs
  • Conclusion
  • References

Quick answer

Paste the JSON response into the JSONPath Tester. Start with $ and add one step at a time: .key for each object level, [0] or another index for an array, and run the expression after every step. When the final step is the field name, the result is that field's single value. If a run returns zero matches, the step you just added names something that is not there; fix that level before going deeper.

Why build the path one level at a time

A JSONPath expression is a chain, and a chain fails at its weakest link. Write the whole path in one guess and a wrong result tells you nothing about which of the five steps was wrong. Build it incrementally and every run is a checkpoint: the result shows exactly what that level selected, so you can compare it against the response and confirm you are standing where you think you are.

The payoff comes when a run returns nothing. Zero matches is a valid result in this tester, not an error message, and on its own it just says the path and the data disagree somewhere. Built level by level, it says something much more useful: every level up to here matched, and this new step is the one that does not. That turns debugging a path from a guessing game into a thirty-second check.

How to extract one field, step by step

  1. Copy the JSON response and paste it into the JSONPath Tester. The tester works on the pasted text, in your browser.
  2. Type $ and run it. The result is the whole document, which confirms the JSON itself is readable.
  3. Add one step for the first level, such as .store, and run again. Check that the result is the part of the response you expected to enter.
  4. Keep adding one step at a time: .key steps for objects, an index such as [0] when you reach an array and want one item from it. Run after each step and check the selection each time.
  5. Finish with the field name itself, such as .title. The result is now the single value you wanted. Copy it, and keep the expression: it will work on the next response with the same structure.

Worked example: one title out of a shop response

Say the response looks like this, and the value you need is the title of the first book:

{
  "store": {
    "book": [
      { "title": "Dune", "author": "Frank Herbert", "price": 9.99 },
      { "title": "Emma", "author": "Jane Austen", "price": 7.50 }
    ],
    "bicycle": { "color": "red", "price": 19.95 }
  }
}

Build the path in runs:

  • $.store returns the store object. Right building.
  • $.store.book returns the array of two books. Right room.
  • $.store.book[0] returns the first book only, the record with the Dune title.
  • $.store.book[0].title returns Dune. One field, one value, done.

Now the failure case. Suppose you had guessed the array was called books and typed $.store.books. The run returns zero matches. Because the earlier steps were checked as you went, you know the problem is at the last step: there is no books key inside store. Shorten back to $.store, look at the keys that are actually there, and the correct name, book, is in front of you.

Reading the result: one match, many matches, zero matches

One match is the clean case: the path ends at a single field and the result is its value. That is what an index step gives you inside an array, because an index names exactly one item.

Many matches means the path passed through a wildcard or a recursive descent on the way down. $.store.book[*].title returns both titles, Dune and Emma, because [*] selects every book before the .title step runs. If you wanted one value and got a list, an index is missing somewhere along the path.

Zero matches means the path is well formed but lands nowhere. Nothing is broken; the expression and the document simply disagree, most often because a key name differs from what you assumed, or an index points past the end of a short array. Treat it as directions: shorten the path until it matches again, and rebuild from there.

Limitations and honest tradeoffs

Selection by value is out of reach. There is no supported way here to ask for the book whose author is Jane Austen, because filters such as [?(...)] are outside the subset and return a clear error naming the part. The practical alternative is an index when you know the position, or [*] to read the field from every item and pick from the short list that comes back.

The path is tied to the structure. If the API renames a key or wraps the array in another object, the expression returns zero matches rather than adapting. That is arguably a virtue for testing, since the failure is visible, but it does mean paths need updating when a response format changes.

Finally, the tester works on what you paste. It does not call the API or fetch a URL, so getting the response into the page is a manual copy, and the result reflects that snapshot, not a live endpoint.

Common mistakes

  • Guessing the whole path at once. When it returns nothing, you have no idea which level failed. One step and one run at a time is faster in the end.
  • Assuming a plural key name. Responses are full of singular collection names like book for an array. Check the actual keys at each level instead of trusting the guess.
  • Forgetting the index. A path that ends at an array returns the whole array, not a field from its first item. Add [0] before the field name.
  • Reaching for a filter. [?(...)] is not supported and returns an error. Use an index, or a wildcard plus your own eyes.
  • Reading zero matches as a tool failure. It is a valid result and the most useful debugging signal the tester gives you.

FAQs

How do I find the right path to a field? Start at $ and add one level at a time, running the expression after each step. Each run shows what that level selected, so you can follow the structure down to the field instead of guessing the whole path at once.

What does zero matches mean? It means the expression is valid but nothing in the document sits at that location. A key name or an index along the path does not match the data. Shorten the path until it matches again; the first level that returns nothing is where the mistake is.

Can I extract a field from inside an array? Yes. Use an index such as [0] for one specific item, or [*] to read the same field from every item. $.store.book[0].title returns the first book's title only.

Is my JSON uploaded to a server? No. The tester runs fully in your browser on the JSON you paste in, so the response never leaves your device.

Can I use a filter to pick an item by its value? Not in this tester. Filters such as [?(...)] are outside the supported subset and return a clear error naming the unsupported part. Use an index for one item, or [*] to read the field from all items and pick from the results.

Conclusion

Extracting one field is a short method, not a long expression: paste the response, start at $, and walk down one verified level at a time until the last step is the field itself. The expression you end up with is documentation as much as a query, since it states exactly where the value lives. If the building blocks themselves are new to you, our explainer on JSONPath syntax basics covers each step type, including brackets and recursive descent, in full. For more guides in this series, see our Data and JSON Tools guides.

References