小编use*_*958的帖子

解析Json的回应回到了Gatling

我试图解析服务器返回给gatling的json响应.

我对服务器的回复是:

SessionAttribute(
  Session(
    GetServices,
    3491823964710285818-0,
    Map(
      gatling.http.cache.etagStore -> Map(https://api.xyz.com/services -> ), 
      gatling.http.cache.lastModifiedStore -> Map(https://api.xyz.com/services -> ),
      myresponse -> {
        "created":"2014-12-16T22:06:59.149+0000",
        "id":"x8utwb2unq8uey23vpj64t65",
        "name":"myservice",
        "updated":"2014-12-16T22:06:59.149+0000",
        "version":null
      }),
    1418767654142,622,
    OK,List(),<function1>),id)
Run Code Online (Sandbox Code Playgroud)

我在我的脚本中这样做:

val scn = scenario("GetServices")
          .exec(http("Get all Services")
          .post("/services")
          .body(StringBody("""{ "name": "myservice" }""")).asJSON
          .headers(sentHeaders)
          .check(jsonPath("$")
          .saveAs("myresponse"))
).exec(session => {
  println(session.get("id"))
  session
})
Run Code Online (Sandbox Code Playgroud)

它仍在打印整个响应.我怎样才能检索到的id是"x8utwb2unq8uey23vpj64t65"什么?

json scala gatling

11
推荐指数
1
解决办法
2万
查看次数

标签 统计

gatling ×1

json ×1

scala ×1