Skip to main content
Version: ACE 5

JSONATA Map

Overview

JSONATA Map allows performing advanced manipulations on the doc nodes using the JSONATA Query Language.

tip

It is possible to explore the possibilities of JSONATA using Web Editor

Configuration

It is possible to define multiple JSONATA mappings with following variables:

  • Jsonata (maps[].jsonata) - a jsonata string for mapping from doc nodes
  • Target path (maps[].targetPath) - node on doc context where to place the outcome
  • Source path (maps[].sourcePath) - Optional field that can be used as the base path for the JSONATA content
  • Map null result (maps[].setNullSource) - if set to true then map to target with null value. By default will not map null values
  • Append result (maps[].append) - when set to true the result will be appended to the target path making the target path an array

Merge Array Items

An optional config to merge items in source and target arrays. The items of both arrays have to be in the same structure.

  • Merge by key (maps[].mergeArrayItems.mergeByKey) - find items to merge by this key
  • Exclude target items (maps[].mergeArrayItems.excludeTargetItems) - an optional JSONATA expression to exclude items in the target when merging

Examples

List mapping

JSONATA Map Example Flow
steps:
- name: Step jsonata
config:
maps:
- mergeArrayItems: {}
jsonata: 'policies.{"PolicyId": Id, "PolicyType": Type}'
targetPath: output
stepType: jsonata
Input document
{
"policies": [
{
"Id": 111,
"Type": "Motor"
},
{
"Id": 222,
"Type": "Home"
}
]
}
Flow result
{
"doc": {
"policies": [
{
"Id": 111,
"Type": "Motor"
},
{
"Id": 222,
"Type": "Home"
}
],
"output": [
{
"PolicyId": 111,
"PolicyType": "Motor"
},
{
"PolicyId": 222,
"PolicyType": "Home"
}
]
},
"errors": [],
"performance": {
"steps": [
{
"step": "jsonata",
"executionTime": 2
}
],
"executionTimeOfFlow": 3,
"timeMetric": "ms"
}
}

Aggregation

JSONATA Map Example Flow
tags:
- general
steps:
- stepType: jsonata
config:
maps:
- mergeArrayItems: {}
jsonata: '{ "total": $sum(cart.(price * quantity)) }'
targetPath: result
name: JSONATA Map
description: ""
condition: ""
sampleData:
cart:
- price: 100
quantity: 10
- price: 120
quantity: 20
- price: 200
quantity: 5
- price: 500
quantity: 3
Input document
{
"cart": [
{
"price": 100,
"quantity": 10
},
{
"price": 120,
"quantity": 20
},
{
"price": 200,
"quantity": 5
},
{
"price": 500,
"quantity": 3
}
]
}
Flow result
{
"doc": {
"cart": [
{
"price": 100,
"quantity": 10
},
{
"price": 120,
"quantity": 20
},
{
"price": 200,
"quantity": 5
},
{
"price": 500,
"quantity": 3
}
],
"result": {
"total": 5900
}
},
"errors": [],
"performance": {
"steps": [
{
"step": "jsonata",
"executionTime": 1
}
],
"executionTimeOfFlow": 1,
"timeMetric": "ms"
}
}