Updated on 2026-08-11 GMT+08:00

Extracting a JSON Object

Function Name

$extractingData(String json, String jsonPath, String mode)

Parameter Description

  • json: Accepts a local parameter, environment parameter, or built-in function. Must be in JSON format.
  • jsonPath: Accepts a string, local parameter, environment parameter, or built-in function.
  • mode: Accepts jayway or fastJson.

Function Description

Extracts a JSON object from the API response for subsequent API test steps, and assigns the object value to other parameters.

Application Scenarios

This function can be used in the following parts of an API automation test case. (Do not use the function for environment parameters. Otherwise, what is input will be output.)

  • Request URL
  • Request header
  • Request body
  • Checkpoint property
  • if condition
  • for loop interrupt condition

Example

  • Request URL

As shown in the URL request in Figure 2, the function for extracting a JSON object is used to extract the value of id returned by the body parameter (as shown in Figure 1) and assign the value to group_id.

Figure 1 Response
Figure 2 Extracting a JSON object

After saving and running the script, you can view the details in the execution history.