- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Nifi jolt transformation to convert Input JSON
- Labels:
-
Apache NiFi
Created on ‎01-08-2021 09:14 PM - edited ‎01-08-2021 10:30 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi All,
I am trying to convert input JSON to Output JSON using Jolt Transformation . My flow," AttributestoJSON" gives some count of flow files and after that i am using "Mergecontent" to merge the flowflies into single flowfile JSON .The single flowfile json passed to jolt transformation.
Input flow file JSON
{"filename":"test1.csv","message":"HiveSQL query executed Sucessfull!","status":"Success"}
{"filename":"test2.csv","message":"HiveSQL query executed Sucessfull!","status":"Success"}
{"filename":"test3.csv","message":"HiveSQL query executed Sucessfull!","status":"Success"}
Output JSON should be :
{
"filename": "${main_file}",
"ex_status": "${Overall_status}",
"error": "${final_message}",
"fl_status": [
{
"file_name": "test1.csv.",
"status": "Success",
"message": "HiveSQL query executed Sucessfull!"
},
{
"file_name": "test2.csv",
"status": "Success",
"message": "HiveSQL query executed Sucessfull!"
},
{
"file_name": "test3.csv",
"status": "failed",
"message": "HiveSQL query executed Sucessfull!"
}
]
}
Here main_file,Overall_status and final_message values , i am getting as flowfile attributes and will include the vaues for that from the attributes . I am exploring JSON specification and did not get the desigred result yet . Please help with Jolt specification for above output JSON .
Thanks
@Nifi@Jolt
Created on ‎01-09-2021 09:30 PM - edited ‎01-09-2021 09:32 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My input JSON will be like below
[ {
"filename":"test1.csv",
"message":"HiveSQL query executed Sucessfull!",
"status":"Success"
}, {
"filename":"test2.csv",
"message":"HiveSQL query executed Sucessfull!",
"status":"Success"
}, {
"filename":"test3.csv",
"message":"HiveSQL query executed Sucessfull!",
"status":"Success"
} ]
