JSONPath Recursive Descent Operator (..)

Learn the JSONPath recursive descent operator (..) to search through all levels of a JSON document. Find deeply nested values without knowing the exact path.

Operators

Detailed Explanation

Recursive Descent in JSONPath

The double-dot operator .. performs a deep scan of the JSON document, searching through all levels of nesting to find matching property names or array elements. It is one of the most distinctive features of JSONPath.

Syntax

$..propertyName     // find "propertyName" at any depth
$..[0]              // first element of every array at any depth
$..*                // every value in the entire document

How It Works

Given this deeply nested JSON:

{
  "company": {
    "name": "Acme",
    "departments": [
      {
        "name": "Engineering",
        "teams": [
          { "name": "Backend", "size": 8 },
          { "name": "Frontend", "size": 5 }
        ]
      },
      {
        "name": "Marketing",
        "teams": [
          { "name": "Digital", "size": 4 }
        ]
      }
    ]
  }
}
  • $..name returns ["Acme", "Engineering", "Backend", "Frontend", "Marketing", "Digital"] — every name property at any depth.
  • $..size returns [8, 5, 4] — all team sizes regardless of their nesting level.
  • $..teams[0].name returns ["Backend", "Digital"] — the first team name in each department.

Common Patterns

  1. Find all IDs: $..id — useful for collecting identifiers scattered throughout a response.
  2. Find all arrays: $..[*] combined with type checks.
  3. Count occurrences: evaluate $..key and check the result length.

Performance Considerations

Recursive descent traverses the entire document tree, so it can be slower on very large JSON structures (megabytes of data). For performance-critical applications, prefer explicit paths when the structure is known.

Comparison Table

Expression Result
$.company.name "Acme" (only root level)
$..name All name values at every depth
$..teams..name Team names only (scoped descent)

Use Case

Use recursive descent when you need to extract a specific field from a complex, deeply nested JSON document without knowing or hard-coding the exact path — for example, collecting all error messages from a nested API response or finding every price field in a product catalog.

Try It — JSON Path Evaluator

Open full tool