I am trying to understand simple jolt transformations , I have a simple 1 level json , I would like to change the sequence of columns and convert into Rows array with Values object repeating with comma separated values, adding current date at the end of Values object. And also add default tags
Sample JSON
{
"name": "john",
"Address2": "123 Street 1",
"Address1": "Apt 101",
"custId": "ZY-1234",
"zip": "67834"
}
Expected JSON
{
"Rows": [{
"values": [
"ZY-1234",
"john",
"123 Street 1",
"Apt 101",
"67834",
"2022-09-01 10:10:09"
]
}],
"operationType": "Insert",
"Source": "Dev"
}
Jolt Spec I have
[
{
"operation": "default",
"spec": {
"ChangedBy": "NIFI",
"ChangedOn": "${now()}"
}
},
{
"operation": "shift",
"spec": {
"*": {
"@": "Rows[#1].Values"
}
}
},
{
"operation": "default",
"spec": {
"*": {
"*": "&"
},
"operationType": "Insert",
"Source": "Dev"
}
}
]
The Result JSON
{
"Rows" : [ {
"Values" : [
"john",
"123 Street 1",
"Apt 101",
"ZY-1234",
"67834",
"NIFI",
"${now()}" ]
} ],
"operationType" : "Insert",
"Source" : "Dev"
}
Issues :
- How to change the column sequence in Values array
- How to get current datetime