1

I have a JSON returned by a RESTful API:

{
    "0": {
        "id": "1484763",
        "name": "Name",
        "values": {
            "0": {
                "value": "Peter"
            }
        }
    },
    "1": {
        "id": "2584763",
        "name": "phone",
        "values": {
            "0": {
                "value": "45456456"
            }
        }
    }
}

How do I write a JSONPath that extracts a phone number value? (so in this case, "45456456"). What makes the problem harder, phone number object is not always inside "1" key.

Sergey
  • 47,222
  • 25
  • 87
  • 129

1 Answers1

0

Try this JsonPath which results in phone number 45456456

$..[?(@.name = 'phone')].values.0.value

Basically, you have to apply a filter ?() where name == 'phone' and then use normal json path.

Try the expression in this link

JsonPath expression syntax can be found here.

parishodak
  • 4,506
  • 4
  • 34
  • 48