smartbear90211
11 years agoOccasional Contributor
JSONPath Expression to assert a list contains a specific element
I'm looking for an expression which checks if an element with id=123 is contained in a json-list.
[
{
"id": "123"
}
},
{
"id": "456"
}
}
]Given the above list, I could use this JSONPath Expression: $[0].id but unfortunately, I can't guarantee that the element is always at index 0. Sometimes it would be $[1].id.
I tried with $[*].id but this extracts [[id1,id2]].
So basically, I'm looking for something like "is 123 equals to $[0].id OR $[1].id" or if that's not possible something like "does $[*].id contains an element "123".
I'm using ReadyApi 1.4.1.