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.

Apache nifi - Split json error when an array has only one record or empty,


Apache nifi - Split json error when an array has only one record or empty,

Do you have any suggestions to fix it,

many thanks


Super Guru

@Thuy Le

Use EvaluateJsonPath processor and add new property to determine length of the array.


Then use RouteOnAttribute processor to check the array_length attribute value and route to SplitJson processor or some other processor.


--other processors
EvaluateJsonProcessor //add array_length property to the processor
RouteOnAttribute //add dynamic properties to check the array_length attribute value.
|(array_length more than 2)                  |(array_length less than 2)
SplitJson                                Some other processors..


thanks @Shu, It doesnot work with when empty json



and also nested json


Super Guru

@Thuy Le

If you have array then configure EvaluateJson processor and add new property as

$.[2].length() //means if you have 2 json objects in array then attribute value will be 1 else empty.

Then by using RouteOnAttribute processor check if the value is empty or 1 and route the flowfile accordingly.

2.What if there is empty json data?

Still processor adds length attribute value as Empty String Set and in RouteOnAttribute processor you can check the value is Empty or not.

Another way of checking will be by using RouteText processor and check is there any data in the flowfile content by adding Regular expression dynamic property in RouteText processor.

Super Guru

@Thuy Le

If the answer is helpful to resolve the issue, Login and Click on Accept button below to close this thread.This will help other community users to find answers quickly 🙂


Sorry, but It dose not work in my side. I guess that you didnot test it


In EvaluateJsonPath is always unmatched

New Contributor

Splits a JSON File into multiple, separate FlowFiles for an array element specified by a JsonPath expression. Each generated FlowFile is comprised of an element of the specified array and transferred to relationship 'split,' with the original file transferred to the 'original' relationship. If the specified JsonPath is not found or does not evaluate to an array element, the original file is routed to 'failure' and no files are generated.


titaniumtv download

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