All,
I'm having some trouble retrieving individual values from the response I'm analysing. The code below is brewed up from some examples i've ran into, but i haven't got much success so far.
The problem is that i am not able to retrieve just 1 object of the object array below, but only the array (without the surrounding []'s ). The log statement prints the whole array of objects without the [] brackets, not just one of the objects inside the array.
My response has the following structure (an array of objects, right?):
[
{
"registerID": "1234",
"expectedDate": "2016-06-21T00:00:00+02:00",
"first": false,
"frequency": "M"
},
{
"registerID": "5678",
"expectedDate": "2016-06-21T00:00:00+02:00",
"first": true,
"frequency": "Y"
}
]
I'd like to walk loop through the objects, and select one of them for further processing (actually, i'd like to get a random entry, but for starters I'm looking at the individual entries first).
For that I'm doing this:
val reports = exec(http("Open report")
.get("/api/reports/2016/${userId}")
.check(status.is(200))
.check(jsonPath("$").ofType[Seq[Any]].findAll.saveAs("repArr"))
).foreach("${repArr}", "item") {
exec(session => {
val itemMap = session("item").as[Seq[Any]]
println(itemMap) // full list/array, not just one item is printed
session.set("tmp","for now")
})
So how should I split up the array in items...?
Regards,
Nol