JSONPath-Plus / JSONPath

A fork of JSONPath from http://goessner.net/articles/JsonPath/
Other
958 stars 169 forks source link

Support For N level filtering #217

Open KieranTH opened 1 month ago

KieranTH commented 1 month ago

Motivation

I would like to be able to filter paths to multiple degrees. This is mainly associated with filtering a dataset based on heavily nested fields, of which may also be arrays.

Current behavior

Does not support - Example:

JSON:

{
  "name": "Test",
  "grouping": {
    "nested_1": [
      {
        "name": "First Level Nest",
        "nested_2": [
          {
            "name": "Second Level Nest"
          }
        ]
      }
    ]
  }
}

Path: $..grouping[?(@.nested_1.nested_2[?(@.name == "Second Level Nest")])]

Desired behavior

Being able to filter to an Nth degree of a dataset through nested filter queries.

If anyone has any idea around this, or possible alternative approaches which don't heavily degrade performance, would love to hear them!