Map Objects v2
Map an object on the Property that consumes or returns it. Declare the target fields under Properties, then map each field from Workflow input or an earlier Step Return.
The examples headed Parameters: are fragments of a consuming Step inside the Workflow's Steps list. Replace that Step's Parameters section in Code view; do not paste them as root Workflow Parameters, which cannot contain Expressions. Each example assumes that the named source Step already exists and exposes the fields shown.
Construct a target object
The target Property names define the object that the receiving Node Method sees:
Parameters:
Customer:
Type: object
Properties:
id:
Type: string
Expression: "{getCustomer.Customer.customerId}"
displayName:
Type: string
Expression: "{getCustomer.Customer.name}"
active:
Type: boolean
Expression: "{getCustomer.Customer.enabled}"
This mapping selects and renames fields without changing the getCustomer Step Return. Match every target field to the type required by the receiving contract.
For example, if getCustomer.Customer contains {"customerId":"C-001","name":"Ada","enabled":true}, the consuming Step receives Customer as {"id":"C-001","displayName":"Ada","active":true}.
Map an existing object
Use a parent Expression when the target can consume the upstream object directly:
Parameters:
Customer:
Type: object
Expression: "{getCustomer.Customer}"
Add child Properties when the target needs a deliberate shape. A pure object reference can establish the source while the children select or transform its fields:
Parameters:
Customer:
Type: object
Expression: "{getCustomer.Customer}"
Properties:
id:
Type: string
Expression: "{getCustomer.Customer.customerId}"
label:
Type: string
Expression: "CONCAT({getCustomer.Customer.code}, \" - \", {getCustomer.Customer.name})"
Do not add a parent Expression merely to make the children valid. An object can be constructed directly from child mappings when each child has its own source.
Nest objects
Add another object Property and declare its children:
Parameters:
Customer:
Type: object
Properties:
id:
Type: string
Expression: "{getCustomer.Customer.id}"
address:
Type: object
Properties:
city:
Type: string
Expression: "{getCustomer.Customer.address.city}"
postalCode:
Type: string
Expression: "{getCustomer.Customer.address.postalCode}"
Use the Canvas Property edit mode to add, rename, change, reorder, or nest target fields. Use Infer a Schema when a Node returns a runtime shape that is not declared completely by its design-time contract.
Select one object from an Array
FIRST and LAST can select an object for nested mapping:
FirstCustomer:
Type: object
Expression: "FIRST({listCustomers.Customers})"
Properties:
id:
Type: string
Expression: "{listCustomers.Customers.id}"
The child mappings run in the selected source scope. FIRST and LAST return null when the collection is empty, so design the receiving contract and error path accordingly.
Validate the result
- Resolve missing-field, scope, and shape errors in
Problems. - Open
Previewand inspect the evaluated child Expressions. - Run the Workflow with representative input.
- Inspect the consuming Step's input and the resulting output in
Logs.
Mapping does not parse JSON or XML text. Use a document parser first, then map the returned object. Literal Value also does not construct a complex object; use nested Properties or a parsed document.
See also
See Map Arrays, Data Mapping, and Object Data Type.