Skip to content

Support multi level filtering in jsonpath #4065

@lillem4n

Description

@lillem4n

Problem to solve

Currently filtering in jsonpath on multiple levels and "and"/"or" operators is not supported.

Proposal

Provided the following example JSON response from an endpoint:

{
  "data": [
    {
      "id": 3,
      "roles": [
        {
          "skutId": "xyz",
          "description": "ffs"
        },
        {
          "skutId": "abc",
          "description": "ffs"
        }
      ]
    },
    {
      "id": 7,
      "roles": [
        {
          "skutId": "xyz",
          "description": "ffs"
        },
        {
          "skutId": "lur",
          "description": "ffs"
        }
      ]
    }
  ]
}

And the following jsonpath: $.data[?(@.roles[?(@.skutId=='lur' || @.skutId=='abc')])].

Should provide an array with two elements, the de-facto content of the $.data .

Additional context and resources

The RFC 9535 proposal seems to implement this, and is done by this online JSONPath evaluator: https://jsonpath.com/ where the above example renders the expected result.

There is a crate that is pretty new and that says itself supporting the full, current RFC: https://crates.io/crates/jsonpath-rust

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions