JSON Payload Mapping

This section provides examples for mapping JSON payloads. In the context of workflow execution, there are three types of mappings:

  1. Input mappings map workflow instance payload to task payload.
  2. Output mappings map task payload back into workflow instance payload.
  3. Merging mappings on end events or sequence flows that lead to parallel gateways.

Input Mapping

Description Workflow Instance Payload Input Mapping Task Payload
Default
{
 "price": 342.99,
 "productId": 41234
}
    
none
    
{
 "price": 342.99,
 "productId": 41234
}
    
Copy entire payload
{
 "price": 342.99,
 "productId": 41234
}
    
Source: $
Target: $
    
{
 "price": 342.99,
 "productId": 41234
}
    
Move payload into new object
{
 "price": 342.99,
 "productId": 41234
}
    
Source: $
Target: $.orderedItem
    
{
  "orderedItem": {
    "price": 342.99,
    "productId": 41234
  }
}
    
Extract object
{
 "address": {
    "street": "Borrowway 1",
    "postcode": "SO40 9DA",
    "city": "Southampton",
    "country": "UK"
  },
 "name": "Hans Horn"
}
    
Source: $.address
Target: $
    
{
  "street": "Borrowway 1",
  "postcode": "SO40 9DA",
  "city": "Southampton",
  "country": "UK"
}
    
Extract and put into new object
{
 "address": {
    "street": "Borrowway 1",
    "postcode": "SO40 9DA",
    "city": "Southampton",
    "country": "UK"
  },
 "name": "Hans Horn"
}
    
Source: $.address
Target: $.newAddress
    
{
 "newAddress":{
  "street": "Borrowway",
  "postcode": "SO40 9DA",
  "city": "Southampton",
  "country": "UK"
 }
}
    
Extract and put into new objects
{
 "order":
 {
  "customer:{
   "name": "Hans Horst",
   "customerId": 231
  },
  "price": 34.99
 }
}
    
Source: $.order.customer
Target: $.new.details
    
{
 "new":{
   "details": {
     "name": "Hans Horst",
     "customerId": 231
  }
 }
}
    
Extract array and put into new array
{
 "name": "Hans Hols",
 "numbers": [
   "221-3231-31",
   "312-312313",
   "31-21313-1313"
  ],
  "age": 43
{
    
Source: $.numbers
Target: $.contactNrs
    
{
 "contactNrs": [
   "221-3231-31",
   "312-312313",
   "31-21313-1313"
  ]
}
    
Extract single array value and put into new array
{
 "name": "Hans Hols",
 "numbers": [
   "221-3231-31",
   "312-312313",
   "31-21313-1313"
  ],
  "age": 43
{
    
Source: $.numbers[1]
Target: $.contactNrs[0]
    
{
 "contactNrs": [
   "312-312313"
  ]
 }
}
    
Extract single array value and put into property
{
 "name": "Hans Hols",
 "numbers": [
   "221-3231-31",
   "312-312313",
   "31-21313-1313"
  ],
  "age": 43
{
    
Source: $.numbers[1]
Target: $.contactNr
    
{
 "contactNr": "312-312313"
 }
}
    

Output Mapping

All examples assume merge output behavior.

Description Job Payload Workflow Instance Payload Output Mapping Result
Default Merge
{
 "sum": 234.97
}
  
{
 "prices": [
   199.99,
   29.99,
   4.99]
}
  
 none 
{
 "prices": [
   199.99,
   29.99,
   4.99],
 "sum": 234.97
}
  
Default Merge without workflow payload
{
 "sum": 234.97
}
  
{
}
  
 none 
{
 "sum": 234.97
}
  
Replace with entire payload
{
 "sum": 234.97
}
  
{
 "prices": [
   199.99,
   29.99,
   4.99]
}
  
Source: $
Target: $
  
{
 "sum": 234.97
}
  
Merge payload and write into new object
{
 "sum": 234.97
}
  
{
 "prices": [
   199.99,
   29.99,
   4.99]
}
  
Source: $
Target: $.total
  
{
 "prices": [
   199.99,
   29.99,
   4.99],
 "total": {
  "sum": 234.97
 }
}
  
Replace payload with object value
{
 "order":{
  "id": 12,
  "sum": 21.23
 }
}
  
{
 "ordering": true
}
  
Source: $.order
Target: $
  
{
  "id": 12,
  "sum": 21.23
}
  
Merge payload and write into new property
{
 "sum": 234.97
}
  
{
 "prices": [
   199.99,
   29.99,
   4.99]
}
  
Source: $.sum
Target: $.total
  
{
 "prices": [
   199.99,
   29.99,
   4.99],
 "total": 234.97
}
  
Merge payload and write into array
{
 "prices": [
   199.99,
   29.99,
   4.99]
}
  
{
 "orderId": 12
}
  
Source: $.prices
Target: $.prices
  
{
 "orderId": 12,
 "prices": [
   199.99,
   29.99,
   4.99]
}
  
Merge and update array value
{
 "newPrices": [
   199.99,
   99.99,
   4.99]
}
  
{
 "prices": [
   199.99,
   29.99,
   4.99]
}
  
Source: $.newPrices[1]
Target: $.prices[0]
  
{
 "prices": [
   99.99,
   29.99,
   4.99]
}
  
Extract array value and write into payload
{
 "newPrices": [
   199.99,
   99.99,
   4.99]
}
  
{
 "orderId": 12
}
  
Source: $.newPrices[1]
Target: $.price
  
{
 "orderId": 12,
 "price": 99.99
}
  

Merging Mapping

workflow

Description Sequence Flow Payload Mapping Result
Default Merge flow1:
{
 "orderId": "XY67C"
}
  
flow2:
{
 "total": 200.00
}
  
 none 
{
 "orderId": "XY67C",
 "total": 200.00
}
  
PUT instruction flow1:
{
 "orderId": "XY67C"
}
  
flow2:
{
 "total": 200.00
}
  
flow2:
Source: $.total
Target: $.sum
Type: PUT
  
{
 "orderId": "XY67C",
 "sum": 200.00,
 "total": 200.00
}
  
COLLECT instruction flow1:
{
 "item1Price": 130.99
}
  
flow2:
{
 "item2Price": 49.99
}
  
flow1:
Source: $.item1Price
Target: $.prices
Type: COLLECT
  

flow2:

Source: $.item2Price
Target: $.prices
Type: COLLECT

{
 "item1Price": 130.99,
 "item2Price": 49.99,
 "prices": [130.99, 49.99]
}