Skip to content

Get Data from JSON Using Key Command: SET_FROM_JSON

The Get Data from JSON Using Key command extracts a specific value from a JSON response using a defined key. This allows you to dynamically retrieve and store data for further use in automation.

Example: Suppose After making an API request, you receive the following JSON response, and you want to extract the User ID from this response:

scrn-example-get-data-from-json-using-key-command

Steps to Configure:

  1. Select Get Data from JSON Using Key from the Action dropdown.
  2. Leave the Screen Name field blank.
  3. In the Element Key field, enter the exact key as it appears in the JSON response (e.g., id).
  4. In the Parameters section, enter the variable name where the extracted value should be stored (e.g., UserID).
  5. Click Save.

Note: While the steps for adding an action command are identical in both views, the display of the steps changes:

scrn-get-data-from-json-using-key-command-tabular-view
Tabular View
scrn-get-data-from-json-using-key-command-card-view
Card View

Expected Outcome on Execution:

  • The command extracts the value 12345 from the id key inside the user object.
  • The extracted value is stored in the variable UserID.
  • This variable can be referenced in later steps using ${UserID} for validation or further API requests.

Notes:

  • Ensure the JSON structure is correctly formatted to match the key you are extracting.
  • If the key is nested, use dot notation (e.g., user.id) to specify the path.
  • Always use the exact key name as it appears in the API response (e.g., id, email, name).
  • The stored value can be used in subsequent steps, such as API requests or assertions.

Back To Top