在Thunder Client中使用JSON查询选择/过滤

发布于 2025-01-30 00:51:10 字数 548 浏览 4 评论 0原文

我正在尝试在VS代码中使用Thunder客户端测试HTTP响应。我得到的HTTP响应是:

{
    "currencies": [
        {
            "name": "Btc",
            "count": 17
        },
        {
            "name": "Ltc",
            "count": 0
        }
    ]
}

我的目标是在某些条件/过滤器上的阵列基础中的每个项目中测试Count字段。我要使用的测试选项是JSON查询。我尝试使用json.currencies [name ='btc']。计数查询,但响应是:

Query: json.currencies[name='Btc'].count > 0 => Actual: undefined

如何在数组内部使用特定条件检查某些属性?

I am trying to test HTTP responses with Thunder Client in VS Code. The HTTP response I get is:

{
    "currencies": [
        {
            "name": "Btc",
            "count": 17
        },
        {
            "name": "Ltc",
            "count": 0
        }
    ]
}

My goal is to test count field in each of the item in the array bases on some condition/filter. The test option I want to use is JSON Query. I tried with json.currencies[name='Btc'].count query, but the response is:

Query: json.currencies[name='Btc'].count > 0 => Actual: undefined

How can I check some property with specific conditions inside of the array?

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

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

发布评论

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

评论(3

慢慢从新开始 2025-02-06 00:51:10

在Thunder Client中,您可以使用索引访问响应数组元素。

因此,请使用JSON.Currencies [0] .Count

In Thunder Client you can access response array element using index.

so use json.currencies[0].count

回眸一笑 2025-02-06 00:51:10

版本1.18.3 按物业内容进行过滤被介绍了。

With the version 1.18.3 filtering by property content was introduced.

活雷疯 2025-02-06 00:51:10

无需围绕BTC

JSON.Curencies [name = BTC] .Count

No need of quotes around Btc

json.currencies[name=Btc].count

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