To be fair Gatling is my first introduction to SCALA so the answer may be obvious to someone but I didn’t see it, and searching on the web did not get me anywhere fast
I was trying to get Gatling to parse the results of a JSON list that may be empty and process the list if it is not empty.
http(“get interesting stuff”)
.get("/appurl/${processid}?sessionid=${sessionid}")
.headers(headers_1)
.check(
status.is(200),
jsonPath("$.doclist[*].id")
.findAll
.saveAs(“dList”))
This worked find and I could process the list if there were any documents attached to the object I was hitting but if the list is empty then I got the error:
jsonPath($.doclist[*].id).findAll.exists, found nothing
Eventually I realized I had to add the following after the .findAll and before the .saveAs:
.transformOption (extract => extract match {
case None => Some(Nil) // couldn’t extract anything, replacing with an empty list
case someNEL => someNEL
}
Enjoy or mock as you please.