如何将 jsonPath 结果保留在 var 中作为 JSON 并重用到另一个 jsonPath 查询?
请求:
var datas:Seq[String] = _
object Search{
val search = exec(http("request_0")
.post(uriString)
.body(StringBody(requestJSON))
.asJSON
.check(jsonPath("$..data[*]")
.saveAs("datas"))
)
}
我尝试过类似的事情......当然没有成功:
object Next{
var current = datas.jsonPath("$..[?(@.id=='"+id+"')]") // ERROR : value jsonPath is not a member of Seq[String]
val next =exec(/*use current variable*/)
}
这个想法是使用 json 输出注入(inject)另一个 http post 请求,就像 feeder 一样。 谢谢
最佳答案
您可以使用任何解析器来解析数据。也可以使用 JsonPath ,它封装在 gatling 中。可以阅读更多关于如何解析@的内容
关于json - GATLING JSON 保存和重用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39660356/