jsonpath find string value in the jsonarray independent of array index jsonpath find string value in the jsonarray independent of array index arrays arrays

jsonpath find string value in the jsonarray independent of array index


You can filter the array with the following:

JsonPath.query("$.error[?(@.errorMessage=='Fixed Error Message')]", json)

EDIT 1:

This would be preferred to check if the message was actually found:

jsonPath("$.error[?(@.errorMessage=='Fixed Error Message')]").exists

If you want to do the .is() check you can try the following (not very nice):

jsonPath("$.error[?(@.errorMessage=='Fixed Error Message')].errorMessage").is("Fixed Error Message")