6.9 Transforming Connectivity Input & Output Data
In some cases it can be necessary to transform the input before it reaches a Connectivity Element or to transform data before the result of a Connectivity Element gets returned.
This can be done using transformers with JSONata expressions, see details at: Using JSONata
info
We recommend applying transformations at the point where input is passed, as described here: Placeholder Resolution
Input transformation
Example for transforming input:
{
"id": "base-dp-transformer-input",
"type": "datapoint",
"version": "0.0.1",
"name": "base-dp-transformer-input",
"displayName": "base-dp-transformer-input",
"tags": [
"simple-example",
"example",
"scenario-example-base",
"scenario-example-base-datapoints"
],
"description": "Example datapoint that demonstrates an input transformer. Uses a JSONata expression to reshape the incoming payload before it is passed to the underlying datapoint execution.",
"datapoint": {
"type": "http",
"http": {
"url": "https://postman-echo.com/post",
"method": "POST",
"headers": {
"Content-Type": "application/json"
},
"body": "${input.body}"
}
},
"input": {
"transformer": {
"transform": "${ {\"id\": input.param} }"
}
}
}
When this datapoint is called with the input:
{
"param": "my_id"
}
This is transformed and the actual input forwarded to the datapoint after transformation is:
{
"id": "my_id"
}
Output transformation
Example for transforming output:
{
"id": "base-dp-transformer-output",
"type": "datapoint",
"version": "0.0.1",
"name": "base-dp-transformer-output",
"displayName": "base-dp-transformer-output",
"tags": [
"simple-example",
"example",
"scenario-example-base",
"scenario-example-base-datapoints"
],
"description": "Example datapoint that demonstrates an output transformer. Uses a JSONata expression to transform the datapoint response into a new structured output before it is returned or passed to subsequent steps.",
"datapoint": {
"type": "http",
"http": {
"url": "https://postman-echo.com/post",
"method": "POST",
"headers": {
"Content-Type": "application/json"
},
"body": "${input.body}"
}
},
"output": {
"transformer": {
"transform": "${ {\"id\": output.param} }"
}
}
}
Note: The output transformer is the only expression where the "output" placeholder can be used, it contains the result of the connectivity element it is defined in.