Support Questions

Find answers, ask questions, and share your expertise
Check out our newest addition to the community, the Cloudera Data Analytics (CDA) group hub.

How to split a flow file and convert sections of it to JSON content using NIFI?

I am consuming messages from IBM MQ using Nifi. Each message is 1000 chars long. Based on the index I have to split the flowfile and then add the splits to JSON object.

e.g. 2525252525M123456789JohnDoe
to : {"Phone":"2525252525", "Sex":M, "Ssn":"123456789", "Name":"JohnDoe" }

Is there a way to do this using any of the Nifi processors. The other approach is to use python or some other script to do that and use Execute Processors. But, if there is some other way please let me know.


Super Guru

@Chandan Singh

You can use QueryRecord processor for this case and use Apache Calcite sql parser.


Add new property to the processor as

select substring(0,9)Phone...etc from FLOWFILE


Define Record Reader(csvreader)/Writer(jsonsetwriter) controller services and resultant flowfile from processor will be in JSON format.

Take a Tour of the Community
Don't have an account?
Your experience may be limited. Sign in to explore more.