【问题标题】:Karate: one liner json path expression not working空手道:一个班轮 json 路径表达式不起作用
【发布时间】:2020-08-04 11:33:29
【问题描述】:

我有一个打印一些东西的两行 json 路径表达式,我想把它全部放在一行中:

Given path 'device/'
When method get
Then status 200

#This correctly prints the value:
And def device_search = $.device[?(@.manufacturer == 'a manufacturer')]
And print device_search[0].id

#This doesn't work (prints null):
And print $.device[?(@.manufacturer == 'a manufacturer')][0].id

谢谢!

【问题讨论】:

  • $.device[?(@.manufacturer == 'a manufacturer')].id[0]
  • 是的,我试过了,但没有成功(null)
  • @italktothewind 哈哈。你真的需要找个魔术师

标签: karate


【解决方案1】:

不支持。使用 2 个步骤。

但如果你坚持,请使用karate.get()

And print karate.get("$.device[?(@.manufacturer == 'a manufacturer')][0].id")

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-05-27
    • 1970-01-01
    • 2014-11-20
    • 2020-09-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多