Reputation: 3711
I'm using Gatling tool to load test my service. I have following response from my server(just an example):
{
"result: {
"288249": {
"allowEdit": 1,
"cells": [
{
"rollupId": "288249",
"description": "Gatling description: 93"
},
{
"rollupId": "288249",
"description": "Gatling description: 83"
}
]
}
}
}
What I need is loop thought all $.result.288249.cells[*].description fields and verify that there's a value, which is equal to what I have in one of my session objects. It should look similar to following pseudo code:
.check(
jsonPath("$.result.*.cells[*].description").contains("${mySessionValue})
)
Is there are method, which I can use in similar way ?
Thanks in advance!
Upvotes: 1
Views: 1961
Reputation: 3711
I think, I've found the solution
.check(
jsonPath("$.result.*.cells[?(@.description == '${mySessionValue}')]")
.find
.exists
)
This should do the work.
Upvotes: 4
Reputation: 1073
You can loop thru as follows
$.each($.result, function(index,obj){
$.each(obj['cells'], function(innerInd, innerObj){
if( ${mySessionValue} == innerObj['description'] )
{
console.log('Found')
return
}
})
})
Upvotes: -1