How to get all properties named ref from a json using jmespath?

Viewed 63

I have a json which is as below:

{
  "ref": "a",
  "details": {
     "ref": "b",
     "properties": [
        { "ref": "c" },
        { "ref": "d" }
     ]
  }
}

I want to get all the values whose property is "$ref" using JMESpath.

I tried ..ref but it didn't work.

Output should be: ["a", "b", "c", "d"]

1 Answers

You tagged JSON Path as well, so here's that answer. Not sure about JMESPath.

You need to start your path with a $.

$..ref

You can see that it works here.

action

Related