Mezoo
Mezoo

Reputation: 769

GATLING JSON Save and reuse

How to keep jsonPath result in var as JSON and reuse to another jsonPath query please ?

Request :

var datas:Seq[String] = _
object Search{
    val search = exec(http("request_0")
                    .post(uriString)
                    .body(StringBody(requestJSON))
                    .asJSON
                    .check(jsonPath("$..data[*]")
                    .saveAs("datas"))
                  )
}

I have tried something like...of course without success:

object Next{
    var current = datas.jsonPath("$..[?(@.id=='"+id+"')]") // ERROR : value jsonPath is not a member of Seq[String]
    val next =exec(/*use current variable*/)
}

The idea is to use json output to inject in another http post request, like a feeder. thx

Upvotes: 2

Views: 3086

Answers (1)

niharika_neo
niharika_neo

Reputation: 8531

You can use any parser to parse the data. Can use JsonPath as well which is packaged in gatling. Can read more on how to parse @

https://github.com/gatling/jsonpath

Upvotes: 3

Related Questions