- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
traverse list of strings of flow attribute in JoltTransformJson processor nifi
- Labels:
-
Apache NiFi
-
NiFi Registry
Created ‎09-18-2022 10:43 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Everyone,
Greetings!
I need help in JoltTransformJson processor.
I have GALLERY_IDS string in flow attribute as mentioned in the below screenshot:
I want to fetch each value from GALLERY_IDS attribute and pass it to JoltTransformJson processor as mentioned in below snapshot
In the output queue, I should get flow file for each gallery with personid.
{"GALLERY_ID:"1","PERSON_ID":"test1"}
{"GALLERY_ID:"2","PERSON_ID":"test2"}
{"GALLERY_ID:"3","PERSON_ID":"test3"}
{"GALLERY_ID:"4","PERSON_ID":"test4"}
{"GALLERY_ID:"5","PERSON_ID":"test5"}
{"GALLERY_ID:"6","PERSON_ID":"test6"}
{"GALLERY_ID:"7","PERSON_ID":"test7"}
Kindly help.
Thanks in advance!
Created on ‎09-19-2022 06:58 AM - edited ‎09-19-2022 07:00 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Is your input in Json format? if its json do you need to completely replace it with the output you specified? If that is the case then you dont need Jolt transformation, instead you can do the following:
1- Place the Gallery_Ids attribute as flowfile content. You can do that using the ReplaceText processor where the Replacement Value is the attribute ${GALLERY_IDS}
2- Do SplitJson to split the Array into a different flow file, this should give 7 flowfiles with the values: 1,2,3,4,5,6 & 7
3- Add another ReplaceText processor that will capture each split from above and replace the flowfile content with the following template in the Replacement Value:
{"GALLERY_ID":"$1","PERSON_ID":"test$1"}
Leave the Search Value as (?s)(^.*$)
This should again give you 7 flowfiles with the expected output format.
Hope that helps, if it does please accept solution.
Thanks
