在我的响应json中,有一个每天更改的日期字段。
这是我的json:
{
"data": {
"0000164": {
"2019-04-03": {
"VALUE": 26
}
}
},
"status": 200
}
从json获取数据,我正在使用命令:$.data.0000164.2019-04-03.OAK
但我想概括一下case.I将日期保存在变量中
例:
* def date = '2019-04-03'
* def hotel = '0000164'
希望通过使用这些值替换酒店和日期字段来获取响应
$.data.hotel.date.OAK
您需要使用jsonPath:https : //stackoverflow.com/a/50855425/10791639
* def date = '2019-04-03'
* def hotel = '0000164'
* def answer = karate.jsonPath(response, "$.data." + hotel + "." + date + ".OAK")
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句