<BUG?> SOAPui 2.3.0 (@.length-1) JSON Path notation
Hi,
I want to assert a content to another content from a previous rest request. Specific example: sorting. I want to make sure that my last result in the list becomes the first when I revert the sorting parameter.
This used to work in 2.2.0. a previous version.
I use the JSONPath expression assertion to check:
current_request_Response_$['List'][0]['Name'] = previous_request_Response_$['List'][(@.length-1)]['Name']
Now SOAPui 2.3.0 cannot retrieve the (@.length-1) it seems. Doesn't matter trying to use dot notation instead of bracket notation, the result is the same.
I can rewrite my assertion to $..List[-1:].Name but then I get a list, because the [-n:] expression always returns lists.... which still fails my assertion as my current_request_Response is not a list value (i.e. does not have [] brackets around it).
Really annoying.
Info I consulted: https://support.smartbear.com/readyapi/docs/testing/jsonpath-reference.html
Error I got:
com.jayway.jsonpath.InvalidPathException: Could not parse token starting at position 1. Expected ?, ', 0-9, *
I got feedback from Smartbear support on this (thanks Marcus!) and think this might be usefull sharing:
Development has confirmed this is a bug with the json-path-2.4.0.jar we are using for JsonPath. There are a number of issues related to @.length, see below links. As a workaround you can use the workaround you posted in the forum or negative array indexes as suggested by Ready API development.
example: $['Lijst'][-1]['Naam']
https://github.com/json-path/JsonPath/issues/300
https://github.com/json-path/JsonPath/issues/338
https://github.com/json-path/JsonPath/issues/450
So for me changing (@.length-1) with -1 works!