Forum Discussion

jsontester's avatar
jsontester
Occasional Contributor
5 years ago
Solved

Assertion for 1 specific value which contains in all results in response

After a GET request where I'm searching for a specific postal code, I get response with 75 results.
I want to assert that all 70 results have the same value for property(postalCode).

If I use the assertions contains option I see JSONPatch Expression:

$['data'][0]['postalCode']


"[0]"shows the first result.

In the expected result I see value "1520"

How Can I assert that all postalCode have the same value "1520"?

What I have tried:

replacing

$['data'][0]['postalCode']

with

$['data'][*]['postalCode']


works but when the result is not 70 the assertion will fail