Search code examples
jsonpath

JSONPath: How to get path if value is present in array?


This is the sample object

{
 "names": [
   "David",
   "Steve",
   "Wilson"
]
...<other properties>
}

I wanted to write query in JSON path to check if "Steve" is present in "name" property of above object and need to return the path if the value exists.

Ref: https://github.com/kawamuray/jsonpath#path-syntax


Solution

  • This path works: $.names[?(@ == "Steve")]

    enter image description here