如何检查密钥是否具有不同的值

发布于 2025-01-29 06:42:02 字数 571 浏览 1 评论 0原文

我遇到了检查特定键的问题。 例如,我有下一个响应

    {
    "content": [
        {
            "first_name": "Agent007",
            "last_name": "007",
            "id": "aa70d1c0-3de4",
            "status": "INACTIVE"
        },
        {
            "first_name": "ALEX",
            "last_name": "Doe",
            "id": "d9d5c211-5388",
            "status": "ACTIVE"
        }
    ]

}

如何检查每个“状态”是否具有“活动”或“不活动”值?

我尝试过,但它不起作用

And assert response.content[*].status == 'ACTIVE' || response.content[*].status == 'INACTIVE'

I faced problem with checking specific key.
For example I have the next response

    {
    "content": [
        {
            "first_name": "Agent007",
            "last_name": "007",
            "id": "aa70d1c0-3de4",
            "status": "INACTIVE"
        },
        {
            "first_name": "ALEX",
            "last_name": "Doe",
            "id": "d9d5c211-5388",
            "status": "ACTIVE"
        }
    ]

}

How to check if each "status" can have "ACTIVE" OR "INACTIVE" value?

I tried this, but it doesn't work

And assert response.content[*].status == 'ACTIVE' || response.content[*].status == 'INACTIVE'

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

时光是把杀猪刀 2025-02-05 06:42:02

这是(只是)一种方法:

* match each response.content[*].status == "#? _ == 'INACTIVE' || _ == 'ACTIVE'"

另一种方法: https:// github。 com/karatelabs/karate#match-ereach

,请参阅此答案以获取高级想法: /70055035/143475

This is (just) one way to do it:

* match each response.content[*].status == "#? _ == 'INACTIVE' || _ == 'ACTIVE'"

Also refer the docs: https://github.com/karatelabs/karate#match-each

And see this answer for advanced ideas: https://stackoverflow.com/a/70055035/143475

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文