JSONPath Nested Filters — Filter on Nested Properties

Learn how to apply JSONPath filter expressions on nested object properties. Access deep values inside filter conditions with dot notation and examples.

Filters

Detailed Explanation

Nested Filters in JSONPath

Nested filters allow you to apply conditions on properties that are buried multiple levels deep within each array element. Inside the [?()] expression, you use dot notation on @ to traverse into nested objects.

Syntax

$.array[?(@.nested.property == value)]
$.array[?(@.level1.level2.level3 > threshold)]

Example

Given:

{
  "employees": [
    {
      "name": "Alice",
      "department": { "name": "Engineering", "floor": 3 },
      "performance": { "rating": 4.8, "reviews": 12 }
    },
    {
      "name": "Bob",
      "department": { "name": "Marketing", "floor": 2 },
      "performance": { "rating": 3.9, "reviews": 8 }
    },
    {
      "name": "Carol",
      "department": { "name": "Engineering", "floor": 3 },
      "performance": { "rating": 4.5, "reviews": 15 }
    }
  ]
}
  • $.employees[?(@.department.name == "Engineering")] returns Alice and Carol.
  • $.employees[?(@.performance.rating >= 4.5)].name returns ["Alice", "Carol"].
  • $.employees[?(@.department.floor == 3 && @.performance.reviews > 10)] returns employees on floor 3 with more than 10 reviews.

How Deep Can You Go?

There is no practical limit to nesting depth in filter expressions:

$.data[?(@.config.database.connection.timeout > 30)]

However, deeply nested filters can be hard to read. Consider restructuring your query or breaking it into multiple steps if the path becomes excessively long.

Combining with Recursive Descent

You can use .. inside filters for even more flexible matching, though support varies by implementation:

$.items[?(@..id == "abc123")]

Tips for Nested Filters

  1. Verify the path exists — if any intermediate property is missing, the filter treats it as a non-match rather than an error.
  2. Test incrementally — start with a simpler filter and add nesting gradually to debug.
  3. Check implementation support — not all JSONPath libraries handle deeply nested filter paths identically.

Use Case

Use nested filters when querying complex JSON structures like organizational data, configuration files with multiple sections, or API responses where the filtering criteria live in nested sub-objects.

Try It — JSON Path Evaluator

Open full tool