The Section TOC - Table of content in the README has may examples for reference. Please have a look there.
an array in the response ?
- Array
as it is
in theassertions
block.- See more examples here, go to section
"Dealing with arrays"
e.g.
- See more examples here, go to section
"assertions": {
"status": 200,
"body": {
"type": "HIGH-VALUE",
"persons":[
{
"id": "120.100.80.03",
"name": "Dan"
},
{
"id": "120.100.80.11",
"name": "Mike"
}
]
}
}
- Also, in case you are only interested in array
size
etc, then below might help-
{
...
"assertions": {
"persons.SIZE": 2
}
}
-or-
{
...
"assertions": {
"persons.SIZE": "$GT.1"
}
}
-or-
{
...
"assertions": {
"persons.SIZE": "$LT.3"
}
}
etc
- In case you want to find an element in the array, then below explains using
JSON Path
-
"assertions": {
"status": 200,
"body": {
"type": "HIGH-VALUE",
"persons.SIZE": 2,
"persons[?(@.name=='Dan')].id.SIZE": 1,
"persons[?(@.name=='Mike')].id.SIZE": 1,
"persons[?(@.name=='Emma')].id.SIZE": 0
}
}