I am trying to parse a json response returned to gatling by the server.
My response from server is:
SessionAttribute(
Session(
GetServices,
349
It might be easiest to use a little bit more jsonPath to pull out the id
you need, storing that in its own variable for later use.
Remember that jsonPath
is still a CheckBuilder, so you can't just access the result directly - it might have failed to match.
Converting it to an Option[String]
seems like a reasonable thing to do though.
So your final few lines would become:
...
.check(
jsonPath("$.id").saveAs("myresponseId")
)
)
).exec(session => {
val maybeId = session.get("myresponseId").asOption[String]
println(maybeId.getOrElse("COULD NOT FIND ID"))
session
})