Created 05-29-2019 02:14 PM
In my flow file I have JSON content which contains an array. How can I extract the size of that array into an attribute (e.g. my.array.size = 5)?
Created 05-30-2019 01:59 AM
You can use SplitJson processor to split the array($.*) into individual flowfile then split json processor adds fragment.count attribute to the flowfile which is array size.
Use UpdateAttribute processor to change the attribute name.
Use MergeContent processor to merge back the content using Defragment strategy.
Created 05-30-2019 01:59 AM
You can use SplitJson processor to split the array($.*) into individual flowfile then split json processor adds fragment.count attribute to the flowfile which is array size.
Use UpdateAttribute processor to change the attribute name.
Use MergeContent processor to merge back the content using Defragment strategy.
Created 06-03-2019 07:07 AM
Thanks, I was hoping for an easy trick because I needed many of these calculations. Maybe I need to write a custom processor for this.
Created 06-04-2019 02:58 AM
Yes,You can consider custom processor/custom script for this, to do this in easier way and add the attribute to the flowfile with array size.
Created 10-13-2022 12:28 PM
You can use EvaluateJsonPath. You only have to add an extra attribute and name it as you want (e.g. count) and set as value "$.my.array.size.length()". Then select Destination and change it to flowfile-attribute. This processor will produce a flowfile which has your extra attribute