Here is an example JOLT transformation that combines two rows without using an array:
Input:
{
"id": "123",
"name": "John",
"age": "30"
},
{
"id": "456",
"name": "Jane",
"age": "25"
}
JOLT transformation:
[
{
// Merge the two objects into one
"operation": "shift",
"spec": {
"0": "&",
"1": "&"
}
},
{
// Concatenate the id, name, and age values
"operation": "modify-overwrite-beta",
"spec": {
"id": "=concat(@(0,id),'_',@(1,id))",
"name": "=concat(@(0,name),' ',@(1,name))",
"age": "=concat(@(0,age),'_',@(1,age))"
}
},
{
// Remove the old id, name, and age keys
"operation": "remove",
"spec": {
"0": {"id": "", "name": "", "age": ""},
"1": {"id": "", "name": "", "age": ""}
}
}
]
Output:
{
"id": "123_456",
"name": "John Jane",
"age": "30_25"
}
In this example, we use the "shift" operation to merge the two input objects into one. Then, we use the "modify-overwrite-beta" operation to concatenate the id, name, and age values from each object into a single value. Finally, we remove the old id, name, and age keys using the "remove" operation.
Asked: 2023-06-26 22:17:42 +0000
Seen: 11 times
Last updated: Jun 26 '23