JSONPath Query

This activity allows you to extract information from a JSON-formatted payload when given the JSON to extract from and the JSON paths you want to be extracted. Instead of having to use complicated regular expressions to parse a JSON, you can use a JSONPath to traverse the JSON’s structure and extract the specific data you want.

Best Practices

Check the Continue Workflow Execution on Failure check box and use a Condition Block to check whether the path query was successful. Fail the workflow if the extraction was unsuccessful. This helps make sure your workflow fails with a useful error message and only continues if the path query succeeds.

Note: There are multiple implementations of JSONPath. Automation uses the Jayway implementation.

Usage

Complete the following properties to use this activity:

  • General
    • Display Name - This name is what's displayed for the activity in the Workflow Editor.
    • Description - A meaningful description may be helpful.
    • Activity timeout (seconds) - Enter the amount of time in seconds that Automation will attempt to complete this activity before it times out.
    • Continue Workflow Execution On Failure - Check this check box to continue the workflow if this activity fails (optional).
    • Skip activity execution - Check this check box to bypass running the activity during the workflow execution (optional).
  • JSON Query
    • Source JSON to Query - Paste the JSON content into the text box, or click the (Variable Reference) icon and choose a variable containing the content.
  • JSONPath queries - Click Add and provide the following information for one or more queries:
    • JSONPath Query - Enter the query, or click the (Variable Reference) icon to use a variable.
    • Property Name - Enter a name for the JSON property.
    • Property Type - Click the drop-down menu and choose the data type of the value.

Once the activity has extracted the data, you can use it in a downstream activity by choosing the property in the Variable Browser.

For example, if you want to return the value from the workflow, use the Set Variables activity to set the workflow's output variable to the value extracted from the JSON:

  • In Variable to update, click the (Variable Reference) icon and choose the desired workflow output variable. 

  • In New value, click the (Variable Reference) icon and choose the property from the JSONPath Query activity.