首页 文章

如何在json响应空手道框架中验证数组

提问于
浏览
1

在下面的示例中,如果 warehouse 是一个数组,我如何验证json响应,如下例所示:

Scenario: using karate's simpler alternative to json-schema
* def warehouseLocation = { latitude: '#number', longitude: '#number' }
* def productStructure =
"""
{
 id: '#number',
 name: '#string',
 price: '#number? _ > 0',
 tags: '##[_ > 0] #string',
   dimensions: {
     length: '#number',
     width: '#number',
     height: '#number'
   },
 warehouseLocation: '##(warehouseLocation)'
}
"""
* def json = read('products.json')
* match json == '#[] productStructure'

我放在哪里#array . 我尝试了不同的问题,但它不起作用 . 谢谢

1 回答

  • 1

    你的问题是要求 warehouse ,在你的例子中我根本找不到 . 我假设你要求这个:

    warehouseLocation: '#[] warehouseLocation'

相关问题