Karate 如何使用[*]JSONPath通配符来检索数组值
我试图从响应中检索Karate 如何使用[*]JSONPath通配符来检索数组值,karate,jsonpath,Karate,Jsonpath,我试图从响应中检索animalId值。数组是动态的,因此我尝试使用def animalIds=response.animals[*].animalId从数组中检索animalId值 答复: { "animals": [ { "animalId": "1234565", "animalName": "Tom" }, { "animalId": "1234567",
animalId
值。数组是动态的,因此我尝试使用def animalIds=response.animals[*].animalId
从数组中检索animalId
值
答复:
{
"animals": [
{
"animalId": "1234565",
"animalName": "Tom"
},
{
"animalId": "1234567",
"animalName": "Dave"
}
]
}
但是,当我执行功能文件时,我收到以下错误:
response.animals[*].animalsId
^ in <eval> at line number 1 at column number 18
com.intuit.karate.exception.KarateException: there are test failures !
at ...(.)
The terminal process terminated with exit code: 1
response.animals[*].animalsId
^在第1行第18列中
com.intuit.karate.exception.karateeexception:有测试失败!
在…()
终端进程终止,退出代码为:1
关于如何解决这个问题,有什么想法吗?应该是:
* def animalIds = $response.animals[*].animalId
阅读文档:应该是:
* def animalIds = $response.animals[*].animalId
阅读文档: