Hi,
I have json data that looks like the following
`
[
{
id:12345,
details: [
{
id: 89823
},
…
]
},
…
]
`
I need to do the following:
Take a random element in the first array, save its id, then pick a random element in the details and save that id. I am having quite a hard at doing that with Gatling and Scala.
I have this code:
`
val browse = exec(http(“API Call”)
.get("/someuri").asJSON
.check(status.is(200), jsonPath("$").ofType[Seq[Any]].findAll.saveAs(“departments”)))
.exec(session => {
val departments = session(“departments”).as[Vector[Any]]
val depBuffer = departments(Random.nextInt(departments.length))
println(depBuffer)
session
})
`
So, this gets me my department but now I have to parse it
I have tried specifying the type more than just Any but always get compiler issues. I can’t find a way to retrieve the value of ${departments.random()} . I can only use this inside a DSL function and none just return the value…
Could I get any direction in getting my ids?