check json query result
Name | Description | Type | Modifier |
---|---|---|---|
json | JSON target document that the query runs against. | String | None |
jsonpath | JSONPath query string | String | None |
expected | (Optional) Expected query result. | String | None |
Given the following JSON document:
{
"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
},
{
"category": "fiction",
"author": "Herman Melville",
"title": "Moby Dick",
"isbn": "0-553-21311-3",
"price": 8.99
},
{
"category": "fiction",
"author": "J. R. R. Tolkien",
"title": "The Lord of the Rings",
"isbn": "0-395-19395-8",
"price": 22.99
}
],
"bicycle": {
"color": "red",
"price": 19.95
}
}
}
To insert the entire JSON document's content above into the json argument, for example, use JSON Editor Online to remove all white spaces. The returned JSON document resembles the following.
{"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},{"category":"fiction","author":"Herman Melville","title":"Moby Dick","isbn":"0-553-21311-3","price":8.99},{"category":"fiction","author":"J. R. R. Tolkien","title":"The Lord of the Rings","isbn":"0-395-19395-8","price":22.99}],"bicycle":{"color":"red","price":19.95}}}
json jsonpath expected
check json query result {"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},{"category":"fiction","author":"Herman Melville","title":"Moby Dick","isbn":"0-553-21311-3","price":8.99},{"category":"fiction","author":"J. R. R. Tolkien","title":"The Lord of the Rings","isbn":"0-395-19395-8","price":22.99}],"bicycle":{"color":"red","price":19.95}}} store.book[0].category reference
- JSONPath of REST Assured, a Java framework for simplifying testing of REST based services and currently employed in TestArchitect, uses Groovy GPath expressions. A tutorial on GPath is beyond the scope of this help system. For more information on GPath, you can refer to this site.
- An empty expected argument results in Pass if the returned JSON is indeed empty; otherwise Fail.
To insert an entire JSON document’s content into the json argument, all whitespaces must be removed manually to avoid automation failure.
Tip:You can use various tools to compact JSON data to remove all whitepsaces. For example: JSON Editor Online.- This action supports the <ignore> modifier. If the string
<ignore>
is present as the value of any of the arguments, or any argument contains an expression that evaluates to<ignore>
, the action is skipped during execution.