【问题标题】:Karate - get all specific field values from a response空手道 - 从响应中获取所有特定字段值
【发布时间】:2019-01-15 04:30:26
【问题描述】:

在 karate 0.6.0 上,以下代码返回一个包含所有 id 的数组:

  • def get = call read('wishlist-products-get.feature') id
  • def wishlist = get.response.wishlist_products

  • ids = wishlist[*].product_info.id

现在在 0.9.0 版本上同样返回以下错误:

wishlist[*].product_info.id, :1:9 需要一个操作数但找到 *

谁能告诉我有什么变化?

谢谢!

【问题讨论】:

标签: karate


【解决方案1】:

您必须使用get 关键字来保存JsonPath 表达式as described in the docs 的结果。

* def ids = get wishlist[*].product_info.id

【讨论】:

  • 或使用* def ids = $wishlist[*].product_info.id
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-08-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多