Checks if json structure in response matches
JsonPath.
JsonPath is XPath equivalent for querying Json structures. Try your JsonPath expressions
online.
This assertion allows you to check the structure of response json.
This method **require
flow/jsonpath > 0.2 library to be installed**.
json
{ "store": {
"book": [
{ "category": "reference",
"author": "Nigel Rees",
"title": "Sayings of the Century",
"price": 8.95
},
{ "category": "fiction",
"author": "Evelyn Waugh",
"title": "Sword of Honour",
"price": 12.99
}
],
"bicycle": {
"color": "red",
"price": 19.95
}
}
}
php
seeResponseJsonMatchesJsonPath('$.store.book[*].author');
first book in store has author
$I->seeResponseJsonMatchesJsonPath('$.store.book[0].author');
at least one item in store has price
$I->seeResponseJsonMatchesJsonPath('$.store..price');
?>