为什么response.item [*]。id在空手道JsonPath中不起作用

问题描述 投票:1回答:1

例如https://github.com/json-path/JsonPath#path-examples$.store.book[*].author可以返回所有书籍的作者;但这不适用于我的代码:* print transactionIds = response.items[*].id

在我的回复中,返回了100个项目,并且通过提供索引号(例如, “ *打印response.items [0] .id”

但是我想获取所有记录ID并放入一个新数组,就像JsonPath#path-examples一样,以获取所有书籍的所有作者。

为什么response.items [*]。id在空手道API测试中对我不起作用?

karate jsonpath
1个回答
0
投票

右侧的JsonPath需要一个$前缀。试试这个:

* def transactionIds = $response.items[*].id
* print transactionIds

请参阅文档:https://github.com/intuit/karate#get

© www.soinside.com 2019 - 2024. All rights reserved.