Transform Node
The Transform Node restructures input data by mapping fields to a new output format.
Define mapping rules to extract values from input paths and assign them to custom output paths.
Purpose
- Data Shaping: Adapt data from one format to another for downstream nodes.
- Simplification: Flatten or extract only the necessary fields.
- Field Renaming: Change the names of keys in a data object.
- Normalization: Standardize disparate data structures into a unified format.
Configuration
Configurable properties:
| Property | Type | Description | Default |
|---|---|---|---|
| label | string (optional) | Descriptive name for the node instance. | 'Transform Data' |
| mappingRules | Array<MappingRule> | Ordered list of rules defining how input fields are mapped to output fields. | [] |
MappingRule Structure
id: string – Unique identifier for the rule.inputPath: string – Path to extract value from the input data.outputPath: string – Path to assign the value in the output object.enabled: boolean – Only enabled rules are applied.
Path Syntax for Input and Output
Important: Define the exact syntax for inputPath and outputPath.
- Path Language: Use dot notation (
user.address.city), JSONPath ($.user.address.city), or bracket notation. - Arrays: How to access/iterate items? (e.g.
items[0].price,items[*].price) - Creation: Does
outputPathauto-create nested objects/arrays if needed? - Missing Input: If an
inputPathdoes not exist, is it omitted or set asundefined? -
Example:
inputPath: "userInfo.id", outputPath: "userId"
Inputs and Outputs
Input (Left Handle):
Receives an object (usually JSON) from upstream.
Output (Right Handle, id: "output"):
Emits a new object after applying all enabled mapping rules.
Logic of Mapping
- Receives input data.
- Initializes an empty output object.
- Iterates over
mappingRulesin order. - For each enabled rule:
- Retrieves value at
inputPathfrom input. - Assigns it to
outputPathin output. - After all rules, emits the final output object.
If multiple rules write to the same outputPath, clarify if last-wins or a merge happens.
Example: Reformatting User Data
Input Data Object:
{
"userInfo": {
"id": "usr_123",
"personal": {
"firstName": "John",
"lastName": "Doe",
"contact": {
"email": "john.doe@example.com"
}
},
"accountStatus": "active"
}
}
Node Configuration:
- label: Reformat User for System B
- mappingRules:
{ id: 'r1', inputPath: 'userInfo.id', outputPath: 'userId', enabled: true }{ id: 'r2', inputPath: 'userInfo.personal.firstName', outputPath: 'customer.firstName', enabled: true }{ id: 'r3', inputPath: 'userInfo.personal.lastName', outputPath: 'customer.lastName', enabled: true }{ id: 'r4', inputPath: 'userInfo.personal.contact.email', outputPath: 'customer.emailAddress', enabled: true }{ id: 'r5', inputPath: 'userInfo.accountStatus', outputPath: 'status', enabled: true }
Output Data Object:
{
"userId": "usr_123",
"customer": {
"firstName": "John",
"lastName": "Doe",
"emailAddress": "john.doe@example.com"
},
"status": "active"
}
Notes and Considerations
- Path Syntax: Double-check path syntax per your implementation.
- Data Types: Types are preserved (e.g., string stays string).
- Debugging: Disable rules to isolate problems or check path validity.
The Transform Node ensures data is in the right format for every step in your workflow.
Loading search features...