Extracting nested JSON with random function


I have the following setup. I create a request which returns a JSON in the following format:

keyLayer1: value
collection: [{
keyLayer2: value,
collection: [{
keyLayer3: value

So I have nested collections. Now I want to save and reuse the value of the keyLayer3 but without specifying the collection indices. I would rather get a random element for each collection.

I did this

.check(jsonPath("$. collection").ofType[Seq[Any]].saveAs(“test”)))

and then for the other call I used the following to get the whole JSON item, but I then can’t extract more values or the collection inside the item.


Any hints on how to extract the keyLayer3 by using random collection indices?

Thanks in advance.

findRandom in upcoming Gatling 3: https://github.com/gatling/gatling/issues/3088

We expect first release candidate next week.

Okay. sounds good.
But is there a way to achieve my goal with a workaround right now?

Okay, I got it working.

I now used the * operator more times in the jsonpath. This way, I could get many items from the json, which I then saved.
In later steps I took the saved value and used the random function on it. This worked fine.