【发布时间】:2021-05-07 10:53:13
【问题描述】:
使用下面的示例测试 url 作为参考,我只想从结果中返回一个值。
http://jsonpath.herokuapp.com/?path=$..book[?(@.price%20%3C=%20$[%27expensive%27])]
通过在最后应用[:1] 尝试它不起作用
【问题讨论】:
使用下面的示例测试 url 作为参考,我只想从结果中返回一个值。
http://jsonpath.herokuapp.com/?path=$..book[?(@.price%20%3C=%20$[%27expensive%27])]
通过在最后应用[:1] 尝试它不起作用
【问题讨论】:
最简单的选择就是使用JSON Extractor 的“匹配号”字段:
-1 - 你会得到两个匹配项
inexpensive_1={"category":"reference","title":"Sayings of the Century","author":"Nigel Rees","price":8.95}
inexpensive_2={"category":"fiction","title":"Moby Dick","author":"Herman Melville","price":8.99,"isbn":"0-553-21311-3"}
inexpensive_matchNr=2
1 - 你会得到第一场比赛
inexpensive={"category":"reference","title":"Sayings of the Century","author":"Nigel Rees","price":8.95}
2 - 你将获得第二场比赛:
inexpensive={"category":"fiction","title":"Moby Dick","author":"Herman Melville","price":8.99,"isbn":"0-553-21311-3"}
0 - 你会得到随机匹配
或者你也可以选择JSON JMESPath Extractor,它有pipe expressions:
store.book[?price<`10`] | [0]
【讨论】: