- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Not Getting Jolt output as expected in NiFi
- Labels:
-
Apache NiFi
Created ‎12-09-2022 02:30 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have below input:
[
{
"seq_no": 18,
"Id": 174052,
"Date": "2021-12-26T00:00:00Z"
},
{
"seq_no": 19,
"Id": 174052,
"Date": "2021-12-26T00:00:00Z"
}
]
Jolt Spec:
[
{
"operation": "modify-overwrite-beta",
"spec": {
"*": {
"seq_no": "=toString",
"Date": "=substring(@(1,REVISION_IND),0,10)"
}
}
},
{
"operation": "shift",
"spec": {
"*": {
"seq_no": "[&1].seq_no",
"Id": "[&1].Id",
"Date": "[&1].Date"
}
}
},
{
"operation": "shift",
"spec": {
"*": "data"
}
},
{
"operation": "default",
"spec": {
"header": {
"submit": "true",
"comments": "3"
}
}
}
]
Output:
{
"data" : [ {
"seq_no" : "18",
"Id" : 174052,
"Date" : "2021-12-26T00:00:00Z"
}, {
"seq_no" : "19",
"Id" : 174052,
"Date" : "2021-12-26T00:00:00Z"
} ],
"header" : {
"submit" : "true",
"comments" : "3"
}
}
Desired Output:
{
"header" : {
"submit" : "true",
"comments" : "3"
},
"data" : [ {
"seq_no" : "18",
"Id" : 174052,
"Date" : "2021-12-26T00:00:00Z"
}, {
"seq_no" : "19",
"Id" : 174052,
"Date" : "2021-12-26T00:00:00Z"
} ]
}
Can you please help how I will get the header part and then the data. I used sort but it's not helping me. Appreciate your help. Thank you.
Created ‎12-09-2022 10:37 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
you can add following object as last step to your JOLT Spec:
{
"operation": "shift",
"spec": {
"header": "header",
"data": "data"
}
}
Greetings
Created ‎12-10-2022 06:46 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @Faerballert ,
Thank you so much. I tried it earlier the same but not sure why it were not working.
some of my fields contains null values. But instead of null I want the empty string in the same jolt. Can we do that? is there any option to do the same.
