Looks like you can easily assert both 1009
and SOME RANDOM MESSAGE
values using JSONPath expressions (in JSON Path Assertion components) but not sure about 123456789
: that's not node value but bode name, and JSONPath implementation used by these components seems has no expressions to get node name.
Suppose you can easily use to assert 123456789
instead binding of JSON Path Extractor (from the same components collection) with jmeter's standard Response_Assertion.
Add 2 JSON Path Assertions as children to the sampler which returns json response you want to process:
Expressions will be $.result.errors..code
and $.result.errors..error
correspondingly.
Add JSON Path Extractor as child to the same sampler to extract full error entry:
Expression: $.result.errors.
.
This will extract {"123456789":{"error":"SOME RANDOM MESSAGE","code":1009}}
and save into the pointed variable (${errorKey}
).
Add Response Assertion as child to the same sampler, after previously added JSON Path Extractor:
This will assert name of the key (123456789
) in the value of ${errorKey}
variable.
So the final construction may look like
...
YOUR Sampler
JSON Path Extractor
JSON Path Assertion
JSON Path Assertion
Response Assertion
...