如何使用空手道 API 解析以下 JSON 响应

How to parse below JSON response using Karate API

任何人都可以在空手道中回答以下问题 API

这里我想从响应中提取 partNumber 和 productTitle,其中响应中的初始数字是动态的,对于每个 get 方法,数字都会改变。

{"items":{'41651625424': {itemCore: {partNumber: '1234567', productTitle: 'Karate API Testing'}}}}

有多种方法,但在这种情况下,对我来说最好的选择是使用 JsonPath:

* def response = { "items": { '41651625424': { itemCore: { partNumber: '1234567', productTitle: 'Karate API Testing' }}}}
* def itemCore = get[0] response..itemCore
* match itemCore == { partNumber: '1234567', productTitle: 'Karate API Testing' }

参考文档:https://github.com/intuit/karate#get-plus-index