Payload Transformation
Payload transformations in LiveDataJob allow you to modify the structure and content of messages using JSONata expressions. Enter your JSONata-compliant transformation expression in the LiveDataJob transformer field to reshape, filter, or restructure message payloads before they are sent to the target endpoint.
Examples
Extract Nested Fields
Extract specific nested fields from a complex message structure:
JSONata Expression:
$exists(document) ? ($ ~> | document | basicInfo |) : null
Input:
{
"$type": "urn:bosch:nexeed:eventtype:entity:v1",
"correlationId": "b011322b-781b-4c4d-b1fc-4adc8aa33459",
"msgId": "a503661f-0190-4992-a93f-57bb04b53099",
"msgSendTime": "2024-12-10T19:43:26.5493394+01:00",
"msgSender": "mes-DataCollector_PDA2",
"msgTopic": "mi/d/JS00/STAG/MES/pda/BCI/FeP/ProcessResult",
"payload": {
"$type": "urn:bosch:nexeed:CustomEntityEventPayload:v1",
"EventId": "b011322b-781b-4c4d-b1fc-4adc8aa33459",
"EventTime": "2024-12-10T19:43:26.5493394+01:00",
"document": {
"basicInfo": {
"contextId": "b011322b-781b-4c4d-b1fc-4adc8aa33459",
"identifier": "Part9044453x87391",
"locationId": "00000000000100100001100010001",
"nioBits": "0",
"procNo": "1000",
"resultDate": "2024-12-10T19:43:26.5493394+01:00",
"resultState": "1",
"typeNo": "1111111111",
"typeVar": "00"
}
}
}
}
Output:
{
"contextId": "b011322b-781b-4c4d-b1fc-4adc8aa33459",
"identifier": "Part9044453x87391",
"locationId": "00000000000100100001100010001",
"nioBits": "0",
"procNo": "1000",
"resultDate": "2024-12-10T19:43:26.5493394+01:00",
"resultState": "1",
"typeNo": "1111111111",
"typeVar": "00"
}
This transformation uses the object transform operator (~>) to remove nested levels, keeping only the basicInfo content. If document doesn’t exist, it returns null.
Flatten Payload Structure
Access data from the payload and flatten the structure:
JSONata Expression:
{
"eventId": payload.EventId,
"eventTime": payload.EventTime,
"partId": payload.document.basicInfo.identifier,
"result": payload.document.basicInfo.resultState
}
Output:
{
"eventId": "b011322b-781b-4c4d-b1fc-4adc8aa33459",
"eventTime": "2024-12-10T19:43:26.5493394+01:00",
"partId": "Part9044453x87391",
"result": "1"
}
Reference Documentation
-
JSONata Documentation - Complete syntax and function reference
-
JSONata Exerciser - Interactive playground for testing expressions