Support Questions

Find answers, ask questions, and share your expertise

Nifi jolt transformation to convert Input JSON

avatar
Contributor

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

1 REPLY 1

avatar
Contributor

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"
} ]