Conditional JsonPath are not working with SoapUI 5.7
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Conditional JsonPath are not working with SoapUI 5.7
After upgrading SoapUI to 5.7, the conditional JSON path used on test assertions is not working. This is working fine with 5.6.1 version
Json path - punches[*].[?(@hasComments==true)].commentsNotes[0].comment.name
Sample JSON response -
{
"startDate": "2022-01-10T00:00:00",
"endDate": "2022-01-10T00:00:00",
"punches": [{
"id": 15800,
"hasComments": true,
"commentsNotes": [{
"id": 387,
"comment": {
"id": -16,
"name": "Dummy Name",
"categories": [{
"id": 3,
"qualifier": "AAAAAA",
"name": "AAAAAA"
}]
},
"notes": [{
"text": "Update note",
"timestamp": "2022-01-22T10:52:09",
"dataSourceDisplayName": "AAA",
"dataSourceId": 11
}]
}],
"isPhantom": false
}]
}
- Labels:
-
REST
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @navneet_goyal ,
it seems to me that your JSONPath tries to apply two selections:
- all punches: [*]
- only punches with [?(@.hasComments==true)]
This JSONPath gives punches with hasComments==true:
$.punches[?(@.hasComments==true)].commentsNotes[0].comment.name
This JSONPath gives you all punches:
$.punches[*].commentsNotes[0].comment.name
I assume the different behavior is caused by the upgrade of Jayway jsonpath library to version 2.4.0. See SoapUI 5.7.0 release notes: https://www.soapui.org/downloads/latest-release/release-notes/ .
Best regards,
Karel
https://apimate.eu
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @KarelHusa
Do you recommend modifying all existing tests to reflect the new format for JSON path or do you expect this behavior might change in future releases of SopaUI?
Thanks,
Navneet
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I cannot predict what happens in future versions of SoapUI, but still do not expect changes in basic JSONPath handling.
There were different opinions in the past how JSONPath should work (some opinions tended to XPath-like behavior) and so it's implementation evolved during the last years. SoapUI 5.7.0 has updated JSONPath Jayway library from 0.9.1 to 2.4.0.
You can check a detailed explanation with examples.
You can also see this thread related to JSONPath changes in SoapUI 5.7.0.
I would recommend to change the JSONPath strings to safer format. And where you are not sure test it (without exposing sensitive data) in https://jsonpath.com/ or similar tool.
Best regards,
Karel
https://apimate.eu
