Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NiFi XML to JSON

Tags:

apache-nifi

I have a NiFi flow that among other things transforms XML into JSON. This is done to prep the data for inserting into MongoDB. I'm using the TransformXML processor and an XSL to do the transform. Is this the correct method? Ordinarily, I would say that XSLT is not the best way to transform XML to JSON but it wasn't able to find another way in NiFi.

like image 393
rennyB Avatar asked Oct 23 '25 12:10

rennyB


1 Answers

If your XML has a specific structure(not dynamic), you can use ConvertRecord processor.

  1. Choose XMLReader for read XML. For this, you must define an avro schema.
  2. Choose JsonRecordSetWriter for write converted result. In this state, if you don't want to change structure, you don't have to change anything on JsonRecordSetWriter.

For more information, I suggest you look at the link below.

https://pierrevillard.com/2018/06/28/nifi-1-7-xml-reader-writer-and-forkrecord-processor/

like image 115
lifeisshort Avatar answered Oct 27 '25 02:10

lifeisshort



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!