英文:
How can I verify json response in Karate?
问题
[
{
"status": "COMPLETED",
"Greeting": "你好",
"API": "Rest"
}
]
现在我需要匹配响应的状态,看它是否是COMPLETED。
我尝试了以下方法,但没有成功。
并匹配 response.status == 'COMPLETED'。我可以这样做吗,还是我需要先存储这个响应?
并匹配 response.status == 'COMPLETED
并匹配 $ == {status:"FAILED"};
英文:
I have one response like below
Below is print response -
[print] [
{
"status": "COMPLETED",
"Greeting": "Hello",
"API": "Rest",
}
]
Now I need to match response status whether it is COMPLETED or not
I tried below things but is not working.
And match response.status == 'COMPLETED'. Can I do this or I need to store this response first ?
And match response.status == 'COMPLETED
And match $ == {status:"FAILED"}
答案1
得分: 1
尝试这样做:
- 匹配 response[0].status == 'COMPLETED'
英文:
Tip: when you see a []
that is a JSON array.
Try this:
* match response[0].status == 'COMPLETED'
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论