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 - a jsonata string for mapping from doc nodes
  • Target path - node on doc context where to place the outcome
  • when enrich result is null - if set to true then map to target with null value. by default will not map null values
  • 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.

  • key - find items to merge by this key
  • jsonata - 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"
}
}