This site uses cookies. By continuing, your consent is assumed. Learn more

148.9fm shares

Validating json response to array

opinion
quepenser.com supports the JSON Schema...

After a request has been sent, Validating json response to array steps exist that can be used to verify the response from the server. Asserts that the response code equals: Asserts that the response code does not equal: Assert that the response reason phrase equals: The comparison is case sensitive. Assert that the response reason phrase does not equal: Assert that the response reason phrase matches the regular expression: The pattern must be a valid regular expression, including delimiters, and can also include optional modifiers.

For more information regarding regular expressions and the usage of modifiers, refer to the PHP manual. Assert that the response status line equals: Assert that the response status line does not equal: Assert that the response status line matches the regular expression: Asserts that the response is in: Assert that the response is not in: Assert that the value of the: Assert that the response body is an empty JSON array [].

How to parse JSON response...

Assert that the length of the JSON array in the response body equals: Assert that the length of the JSON array in the response body has a length of at least: Assert that the length of the JSON array in the response body has a length of at most: The comparison is case-sensitive. The expression must be a valid regular expression, including delimiters and optional modifiers.

How to parse JSON response...

Used to recursively match the response body or a subset of the response body against a JSON blob. In addition to regular value matching some custom matching-functions also exist, for asserting value types, array lengths and so forth.

There is also a regular expression type matcher that can be used to match string values. Notice that the order of the values in the arrays does not matter. To be able to target specific indexes in an array a special syntax needs to be used.

Please refer to Custom matcher functions and targeting for more information and examples.

News feed