i have an issue with Gatling. i want to do something simple.. lets say i have this Json in this variable and want to do a loadrunner style IDX. Somehow this is not possible??
- get the count of where user == same
- pick a random number from 0 to the above count
- pick the corresponding book_title and put it in a variable
val testjson = """{
"Books": [
{
"book_title": "bookTitle21",
"user": "same"
},
{
"book_title": "bookTitle73",
"user": "same"
},
{
"book_title": "bookTitle0",
"user": "admin"
}
]
}"""
so the outcome would be something like
val userCount = JonPath("$.Books.length").as[Int]
val randomIndex = util.Random.nextInt(userCount)
val randomBook = JsonPath("$.Books[#{randomIndex}].book_title", testjson) //this does not work
see the problem description;
tried alternatives like jmespath and jackson
If the current json is from a response body, you can use the
findRandommethod to extract a desired value, save, and then use it through aSession.