Created on 12-10-2018 08:05 PM - edited 08-17-2019 03:55 PM
Hi, please, how to add a tag at the beginning of json with JoltTransformJson?
In the attached image I added a tag to the end of json, what syntax to add at startup?
Created on 12-10-2018 11:48 PM - edited 08-17-2019 03:55 PM
I think you need to use another JoltTransformJson processor and keep your desired order of fields in this processor.
Example:
in the above example i have jolt spec with key values specified which order i need to get them in the resultant flow, same way you can keep your desired order in the second JoltTransformJSON processor.
You can also try using JoltTranfromRecord processor starting from NiFi-1.8 where we can specify Record Reader/Writer controller services as we can have desired order of fields.
In case if you are adding only one key/Value to your json message then consider UpdateRecord processor and keep your default values for Flag field and specify RecordReader/Writer controller services in this case you can add the field and arrange your fields in the desired order using only one processor.
Refer to this link for more details regards to UpdateRecord processor usage.
Created on 12-11-2018 01:37 AM - edited 08-17-2019 03:55 PM
If you are trying to add header/trailer to your existing JSON then try comparing between
ReplaceText processor vs JoltTrasnformProcessor
ReplaceText Configs:
Search Value
(?s)(^.*$)
Replacement Value
{ "messageType":["urn"], "message":{ "arquivo":$1 } }
Character Set
UTF-8
Maximum Buffer Size
1 MB //increase this value if flowfile size is more than 1 MB
Replacement Strategy
Regex Replace
Evaluation Mode
Entire text
By using ReplaceText processor we are adding header/trailer to the flowfile, i could say probably "JoltTransformRecord" processor will give most performance.
Please do load/performance test between JoltTransformJSON processors vs ReplaceText vs JoltTransformRecord (if you are using NiFi-1.8) and let us know which processor worked best for your case 🙂 !!
Created on 12-11-2018 12:31 AM - edited 08-17-2019 03:55 PM
Hi Shu, in my case I just need to add a header and a trailler to my json? What would be the most performatic way to perform this procedure in nifi? Here is an example of the input of my json and how it should stay.