json - GATLING JSON 保存和重用

标签 json scala gatling

如何将 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 中。可以阅读更多关于如何解析@的内容

https://github.com/gatling/jsonpath

关于json - GATLING JSON 保存和重用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39660356/

相关文章:

json - 在 Angular 中继器中使用 groupBy

json - Play 2.6中的Joda DateTime格式不起​​作用

scala - 如何将 sbt 连续测试与 eclipse scala ide 结合起来?

gradle - 在Gradle中将Manifest jar与JavaExec一起使用时找不到主类

scala - 加特林将数据从 feeder 传递到 exec

javascript - Node.js 填充 JSON 请求的最佳实践

ruby-on-rails - 向 ActiveRecord 对象添加附加数据

javascript - typescript 数组未定义

scala - Spark中的FP增长模型

斯卡拉 :- Gatling :- Concatenation of two Maps stores last value only and ignores all other values