Path in Circuit | Online Help | Circuit | JSON Path: Navigating and Extracting Data in JSON Objects | Quick Guide

JSON Path

Path serves to locate specific parts or components within a JSON object. These paths start with the '$' symbol and follow JSONPath syntax. It is used to access particular elements or values within JSON objects passed in the Input Path, Output Path, and Result Path by describing their attributes. It's like using a navigation system to find your way to the intended destination (elements/values) within the JSON data.

Using JSON Paths - A Quick Guide:    

This section details how to use JSON Paths to navigate and extract specific data from a JSON object. We'll illustrate these concepts using an example of an Employee Onboarding process that has the following JSON data as input:

{
"employee_id": "E12345",
"name": "John Doe",
"department": "Engineering",
"onboarding": {
"start_date": "2023-08-01",
"training_programs": [
"Orientation",
"Technical Skills",
"Company Policies"
],
"completed": true
}
}


Accessing Object Properties   

A value assigned to a property, say "propertyName" in a JSON object, can be accessed using the format $.property_name.

For example:

  • $.employee_id returns "E12345."

  • $.name returns "John Doe."

  • $.department returns "Engineering."


Accessing Array Elements   

Similarly, to access any elements within an array at the specified index or index range, the conventions are:
  • $.array_name[index] - Accesses an element within an array at the specified index.
  • $.array_name[start:end] - To access elements within an array index range (start to end). The slice notation [start:end] specifies that you want to include elements starting from the index start up to, but not including, the element at the index end.
  • $.array_name[start,count] - To access elements within an array, where "start" denotes the beginning index, and "count" specifies the number of elements you want to retrieve.
  • Example:
    • $.onboarding.training_programs returns the array ["Orientation", "Technical Skills", "Company Policies"].
    • $.onboarding.training_programs[0:2] returns ["Orientation", "Technical Skills"]. In this case, start is 0, and end is 2, which means you want to include elements at index 0 and 1, but not the element at index 2.
    • $.onboarding.training_programs[1,2] returns ["Technical Skills", "Company Policies"], located at index 1 and index 2.
 

Accessing Nested Properties     

  • $.outer_property_name.inner_property_name - To access properties of a JSON object nested within another JSON object.

  • Example:

    • $.onboarding.start_date retrieves "2023-08-01."
    • $.onboarding.completed gives you the boolean value "true."
For advanced JSON path usage and more filtering capabilities, refer here.

Access data from process Context: $$. (Process Context)  

By using the following JSON path expression, data from the Context Object can be extracted. As you might know, Context Object is JSON data that has more information on the current execution and Circuit state at run time. Refer to Context Object for more details.  

This path expression is used to extract data from the process context rather than the input. Adding $$ to the beginning of a path specifies that you are looking for information within the context object. 


Syntax:
$$.<JSON_Key> (replace 'JSON_Key' with the specific field name in the Context Object you want to retrieve).

Example:
If the previous state sets the following as its output:

{
   "execution_name": "test-case-1"
}

You can access the full object from the key 'execution_name' using the JSON path expression $$['execution_name'] or $$.execution_name.





    • Related Articles

    • Output Path

      Output Path enables you to select a portion of the state's output and transfer it to the next state for processing, eliminating any unecessary objects from the JSON output. If the Output Path isn't specified, the entire JSON node (determined by the ...
    • Input Path

      Input Path enables you to filter and control the actual input passed to the state. By defining an Input Path (either in Builder View or Code View), using JSONPath notation, you can select a portion of the JSON input and use it for processing within ...
    • Result Selector and Result Path

      Result Path and Result Selector are employed to extract dynamic data from the state's result when the execution is successful. Result Selector Result Selector lets you retrieve and process the runtime data, enabling flexible and dynamic data ...
    • Error Selector and Error Path

      Error Selector and Error Path are used to manage errors in a system. While Result Selector and Result Path control the output of a state upon successful execution, Error Selector and Error Path come into play when the are exceptional circumstances, ...
    • Advanced Fields

      Lookups Lookups are fields used to obtain a subset of options from available values in fields, tables, webhook API responses, or database query responses. Existing data available in the organization can be reused using lookups. Lookups usually return ...

    You are currently viewing the help articles of Qntrl 3.0. If you are still using our older version and require guidance with it, Click here.