在Thunder Client中使用JSON查询选择/过滤
我正在尝试在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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在Thunder Client中,您可以使用索引访问响应数组元素。
因此,请使用
JSON.Currencies [0] .Count
In Thunder Client you can access response array element using index.
so use
json.currencies[0].count
用版本1.18.3 按物业内容进行过滤被介绍了。
With the version 1.18.3 filtering by property content was introduced.
无需围绕BTC
JSON.Curencies [name = BTC] .Count
No need of quotes around Btc
json.currencies[name=Btc].count