Skip to content

Return paths to the find nodes #206

Open
@kazoompa

Description

@kazoompa

Hi,

I was wondering if JSONata has or will have a functionality to return the full path(s) to the found nodes in a JSON document as in JSONPath?

Suppose you have a collection of JSON nodes as below:

{
  "data": [
    {
      "guid": "BBC8D8F5-5276-B8D0-89AC-1B19D7D52B34",
      "timestamp": "2000-01-02T19:18:22Z",
      "context": [
        "BD3B518D-75DE-52D1-576C-26BE4C49DB18",
        "BA1169B5-CC73-5F3D-8479-A183EA5637BB"
      ],
      "type": "CONNECTOR",
      "info": {
        "destination": {
          "ipAddress": "221.38.201.23"
        },
        "protocol": {
          "ip": "tcp"
        },
        "port": "8080"
      }
    },
    ...
  ]
}

And you have a this query **[ipAddress ~> /^221\.38/]. Instead of just getting the values, is there a way to get the path to the found nodes? In JSONPath you could do a query as above and get collection of paths as below:

[
   "$['data'][88]['info']['destination']",
   ...
]

Best,

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions