I am trying to virtualize rest api using request and response pair.
request will be get trying to acess players of a team and response will give playes of team and in json format.
but i want response to be sorted in alphabetical order of players.
can this be done?
Sorry, I am not aware of any OOTB filter, assertion, or step for sorting data in JSON arrays.
Some options are:
- Use live recording to capture the responses exactly as they are sent from the live system
- Externalize the array into a DBMS, use a query to retrieve & sort the data, dynamically insert the array into the response object
- Implement a script (JSR step or scripted assertion) to access the response JSON array and sort the results (e.g., Google GSON API)
- Sort the arrays in the rsp.txt file before running the R/R pair recorder
I suppose it is possible to create a custom step that could sort the array. However, from a product perspective, identifying the elements to sort, which elements to exclude, and the element keys considered on the sort could create a lot of complexity. For example, does the script sort every element in the JSON (squad, team name, players, cache, provider, creditLeft, etc.), only team name, or a subset within the hierarchy (team name and players). By which key element does the logic sort, pid or name, and is the sort sequence ascending, descending, or a combination of both (i.e., sort teams in descending order, but player names within the team in ascending order)
only by player name
i found this doc but not able to understand. can you please help me with it.
Sorting and filtering the response from your REST API
Humm... I'll have to take a look.
sure. do let me know if you get anything.
This must be feature implemented by Virtual API Cloud after the virtual response is selected. I do not see any similar feature / capability in DevTest 10.1. Perhaps, one of my colleagues has seen something different.