Karate DSL : Working with json path

If you are new to Karate DSL , Please follow this link to know more.

While I was working with karate, for asserting some values from json response, I encountered an issue with json path.

If you have worked with json path with rest assured or java, typically we use json path with root element and provide expected value as a json object not as array.

But Karate has a strict policy on working with json path.

response = [{ “Name”:”Avishek”, “id”:”1″}]

To assert the value of Name, we use
response.Name == “Avishek”

However this wont work with Karate. It has to be this way:
response[*].Name == [‘Avishek’]

Karate always returns an array when we use * (wild card).

Leave a Reply