如何使用 JSON 路径提取器过滤后从列表中 return 单个值?

How to return single value from list after filter using JSON Path extractor?

使用下面的示例测试 url 作为参考,我只想 return 结果中的一个值。

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 which has pipe expressions:

store.book[?price<`10`] | [0]