I have a request which produces below response:
{
\"totalRows\": 10,
\"colDefs\": [
{
\"entityAttributeId\": \"somestring\",
\"headerName
I found the solution by this way:
Store the JSONArray values with the help of jsonpath:
And def temp = $ListDataSet_Response.rowData[*].3
Call the sort functions directly in the feature file itself.
These lines added in feature file Background:
* def ArrayList = Java.type('java.util.ArrayList')
* def Collections = Java.type('java.util.Collections')
Added these line for Sorting in Ascending order:Created list and added values to this temp variable(stored response) into that list.Later,Applied sorting over that list.
And def listAsAscending = new ArrayList()
* eval for(var i = 0; i < sometextid.length; i++) listAsAscending.add(sometextid[i])
* eval Collections.sort(listAsAscending, java.lang.String.CASE_INSENSITIVE_ORDER)
* print listAsAscending
Similarly for Descending order:
And def listAsDescending = new ArrayList()
* eval for(var i = 0; i < sometextid.length; i++) listAsDescending.add(sometextid[i])
* eval Collections.sort(listAsDescending, Collections.reverseOrder())
* print listAsDescending
To compare the list, with my sort API response later:
* match sortedTemp == listAsAscending
* match sortedTemp == listAsDescending