拥有包含多组乐器(>100+)的 JSON 响应。如何将每个项目集
item_list
值与 item_number
和 item_info
的精确总和或串联进行最佳匹配。
验证在低于总和或串联时失败:
* match each response[*].item_list = $response[*].item_number + "--" + $response[*].item_info
[{
"item_number":01,
"item_info": "Piano",
"item_list": "01--Piano"
},
{
"item_number":02,
"item_info": "Mrudanga",
"item_list": "02--Mrudanga"
},
{
"item_number":03,
"item_info": "Guitar",
"item_list": "03--Guitar"
},
{
"item_number":04,
"item_info": "Flute",
"item_list": "04--Flute"
},
...
...
...
...
...
]
* match each response contains { item_list: "#(_$.item_number + '--' + _$.item_info)" }
您可能需要做一些预处理:
* def data = response.map(x => String(x.item_number).padStart(2, '0') + '--' + x.item_info)
* match response[*].item_list == data