JMESPATH does not contains/starts_with
Asked Answered
S

1

5
{
  "data": {
    "edges": [
      {
        "node": {
          "id": "ABC12345",
          "tags": [
            {
              "name": "Dummy"
            },
            {
              "name": "HelloT"
            }
          ]
        }
      },
      {
        "node": {
          "id": "XYZ123",
          "tags": [
            {
              "name": "Testing"
            },
            {
              "name": "Test"
            }
          ]
        }
      }
    ]
  }
}

I would like to use jmespath on the above json: Return the node if the node.tags[].name that does not contain any Hello* (starts_with)

I have tried the following

(data.edges[].node)[? (tags[])[? !starts_with(name, 'Hello')  ] ]

However it is still returning the first node because it has the tags.name == 'Dummy'

Any advice?

Satiable answered 30/10, 2020 at 3:2 Comment(0)
H
6

Ran into the same; turns out wrapping the command (in your case, starts_with) in parentheses should do the trick.

(data.edges[].node)[? (tags[])[? !(starts_with(name, 'Hello')) ] ]

Horseshit answered 17/9, 2021 at 17:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.