The OUTPUT DATA operator is used to send the processing results of a GRAVITY project to an external system when the project is invoked as a Web Service.
Specifically:
- the operator retrieves the data stream from the input bus (records and columns),
- automatically converts it into JSON format using the
JSON Format Editor
- and then returns the data to the external system that initiated the GRAVITY application as a Web Service.
The OUTPUT DATA operator works together with the INPUT DATA operator, which receives input data from the client. Together, they form a complete communication channel that enables GRAVITY projects to integrate with external systems — both for receiving data and returning it after processing is complete.
Example of a GRAVITY project using the OUTPUT DATA operator:
OPERATOR CONFIGURATION
The Output Data Name field specifies the name of the data set generated by the operator in the “Output_data” section of the JSON structure returned to the client that invoked the Web Service.
The operator provides two ways to process input data (Source type field) into output data in JSON format:
- Create json → Allows you to create a JSON format template based on bus bits. To do this, use the DEFINE JSON SCHEMA, option, which opens the user-friendly
JSON Format Editor. With this editor, you can easily build even highly complex data structures in a simple and intuitive way.
- Use direct json from bit → Use this option if the input bus contains a data bit that stores JSON-formatted data and you want to pass that data (from any node) to the operator’s output.
- Source data bit → The bus bit containing data in JSON format.
- Path to the node to extract → Specifies the node from which the data should be passed to the operator’s output.
- (.) → access to an object’s property, e.g.,
output_data.data(ifoutput_datais an array, each element will be included), - [] → array indexing, access by name or index, e.g.,
output_data[0].data - * → refers to all elements of an array, e.g.,
output_data[*].data - [index] → refers to a specific element, e.g.,
output_data[1].data - if a node or property name contains spaces, treat it as a special case and enclose it in brackets and single quotes:
['output_data'][*].['data'][*].['sub data'][0] - Result node name → The name of the node under which the data will be placed in the operator’s output.
During process execution, the operator processes the input bus data according to the JSON schema definition. If the schema contains nesting levels, the input data will be grouped according to those levels.
If you want to send the entire contents of the bit to the operator’s output, leave this field empty. If you want to extract data from a specific node, use a path expression based on JSONPath notation.
General rules for creating an expression:
Example of use
Data in JSON format:
Further examples:
output_data.data
[
{
"id": 1,
"name": "name1",
"sub data": [
{
"pos": 11,
"pos_name": "pos11"
},
{
"pos": 12,
"pos_name": "pos12"
}
]
},
{
"id": 2,
"name": "name2",
"sub data": [
{
"pos": 21,
"pos_name": "pos21"
}
]
}
]output_data.data[0]
{
"id": 1,
"name": "name1",
"sub data": [
{
"pos": 11,
"pos_name": "pos11"
},
{
"pos": 12,
"pos_name": "pos12"
}
]
}['output_data'][*].['data'][*].['sub data']
[
{
"pos": 11,
"pos_name": "pos11"
},
{
"pos": 12,
"pos_name": "pos12"
},
{
"pos": 21,
"pos_name": "pos21"
}
]Keep in mind that the bus may contain multiple data records, and each record includes a bit whose value stores JSON-formatted data used as the Source data bit.
In this case, the result of the processing will be a JSON object containing the combined data generated from all records.
Example for the condition: ['output_data'][*].['data'][*].['sub data'] with the value set in the data_out field:
"data_out" : [
{
"pos": 11,
"pos_name": "pos11"
},
{
"pos": 12,
"pos_name": "pos12"
},
{
"pos": 21,
"pos_name": "pos21"
}
]This result will be supplemented with operator data and process information, and the final output sent to the client will be: