Support Questions
Find answers, ask questions, and share your expertise

flatten json using nifi

flatten json using nifi

Hello All,

I want to flatten json records using nifi. The records are store in kafka as AVRO. I use the ConsumeKafkaRecord processor to convert avro to json. For flattening I would like to use the JoltTransformJSON processor, but this doesn't work since it expect as input a single json and not an array of json records.

Any ideas, how I can do this ?

Ideally is that I don't have to convert the records to json, but it seems that currently there is no processor to flatten avro.

Regards,

Chris

3 REPLIES 3

Re: flatten json using nifi

Super Guru
@chris herssens

After convert Avro to json processor use SplitJson processor with below configurations in it, if your data is having json Array then SplitJson processor split the array and every flowfile would be single record.

40809-splitjson.png

then use JoltTransform processor to flatten the json record.

Flow:-

ConsumeKafka--> convertAvroToJSON-->SplitJSON-->JoltTransform

Re: flatten json using nifi

I have done this, but this gives performance issues.

I found how to do this with the JoltTransform processor.

Re: flatten json using nifi

could you please share the nifi template for this. I am not able to achieve this.