Any system is defined by the data it receives as input, the way it processes that data, and the output it generates. In a Circuit execution, the input to the circuit is provided as JSON key-value pairs. This JSON is passed as input to the initial state and the processed output is passed as input to the subsequent state in the Circuit. Each state handles JSON input and produces output in JSON format, until reaching an end state or a terminal state like Success or Failure.
Here, we'll explore how JSON data is passed from one state to another within a circuit and how the JSON data transforms during this process. This requires an understanding of the field structures in the Input and Processing of the Circuit and their significance in data selection and filtering.
The flow of JSON input and output data between different states of a circuit can be regulated, managed, and manipulated through the different types of fields explained below:
InputPath - Filters the state's JSON input by restricting the input passed to the state as required or by relevance.
Parameters - Used to add a collection of key-value pairs to the state's input to incorporate new values, exclusive to specific states.
Result Selector - Refines and filters the task output (state's result) by picking up the required elements in the result object and constructing the key-value pairs. This allows us to choose what to pass to the next field, ResultPath.
ResultPath - Customize a state's output by merging its input and result(ie., via Result Selector), enabling the transmission of modified JSON to the next state for processing. It helps to replace, augment, or adjust the State Input using the task's result.
OutputPath - Determines the final result of the state. This is what serves as the input for the next state enabling further refinement of the information. If not defined, ResultPath controls the State Input for the subsequent task.
The below diagram illustrates the flow of JSON data within a task state.
It is essential to specify the respective location or path of data within the Input, Output, and Result datasets for further processing. The conventions for defining the specific data path required from the input, output, and result data sets are explained in the JSON Path article.