Schema and paths

JSONPath query guide with practical examples

Learn how to select properties, array records, recursive fields, slices, unions, and filtered values from JSON.

10 min read Reviewed July 19, 2026 Professional reference

Document summary

A practical JSONPath reference that connects query patterns to real nested response structures.

Key takeaways

  • Use strict, representative input before relying on output.
  • Review structure, types, and edge cases instead of checking only visual formatting.
  • Continue examples inside the connected Bacodev tool to verify the result.
01

Start every query from the root

The dollar symbol represents the complete JSON document. Add property names or array selectors to move through the structure.

02

Use the right selector

QueryPurpose
$.user.nameDirect property
$[0]First array item
$.items[*].idOne field from every record
$..emailEmail fields at any depth
$.items[0:5]First five items
$.items[?(@.active==true)]Basic filtered records
03

Use bracket notation for unusual keys

Keys containing spaces, hyphens, dots, or leading numbers should use bracket notation such as $['order-id'].

04

Test queries against representative records

  1. 1

    Load the complete structure.

  2. 2

    Start with a direct path.

  3. 3

    Add wildcard or recursion only where needed.

  4. 4

    Check both matching and non-matching records.

  5. 5

    Copy the exact path returned by the tool.

05

JSONPath implementations differ

06

JSONPath syntax in one table

JSONPath locates values inside a JSON document with a path expression, similar to how XPath works for XML. The same expression can be reused across tools and libraries that follow the common JSONPath conventions.

  • $ selects the root of the document
  • .name selects a property called name
  • ..name finds every property called name at any depth
  • [0] selects the first element of an array
  • [*] selects all elements of an array
  • $..book[?(@.price > 10)] filters books by a condition
07

Test a path before you use it in code

  1. 1

    Open the JSONPath tester and paste your document.

  2. 2

    Enter the expression you plan to use, for example $.items[0].name.

  3. 3

    Check the matched results and the count against what you expect.

  4. 4

    Refine the expression until it selects exactly the values you need.

08

Frequently asked questions

What is the difference between . and .. in JSONPath?

A single dot selects a direct child property; the double-dot recursive descent selects the property at any depth below the current node.

How do I filter array items in JSONPath?

Use a filter expression in brackets, for example $..items[?(@.status == "active")]. Filter operators include ==, !=, <, >, and logical && and ||.

Does JSONPath work the same in every library?

Most libraries follow the original JSONPath proposal, but some differ on filter syntax and functions. Test your expression in the tool before relying on it in code.

Is my JSON uploaded while testing paths?

No. The tester runs locally in your browser and never uploads the document.

Jump to tool

Apply this workflow in the Jsonpath Tester tool

Open tool