Updated on 2024-04-25 GMT+08:00

Obtaining the Element Values of an Array via Reverse Index

Function Name

$getReverseItem(StringA, StringB, intC)

Parameter Description

  • StringA: array or list element path of the response body or response header.
  • StringB: property name of the array object.
  • intC: subscript of the array in reverse order. 0 indicates the last array, and 2 indicates the last but one array.

Function Description

Obtains a specified element value of an array from a response body or header based on the reverse index.

Application Scenarios

The built-in function for obtaining the element values of an array during response extraction based on the reverse index can be used for API automation.

Example

As shown in the following figure, the property value of the response parameter name is the element value of the array obtained via reverse index. Parameter A in the function is the response body property result, parameter B is the parameter name name in the last N+1 array in the result, and parameter C is 0.