Skip to main content

SplitJson

Description

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.

Tags

json, jsonpath, split

Properties

In the list below required Properties are shown with an asterisk (*). Other properties are considered optional. The table also indicates any default values, and whether a property supports the NiFi Expression Language.

Display NameAPI NameDefault ValueAllowable ValuesDescription
JsonPath Expression *JsonPath ExpressionA JsonPath expression that indicates the array element to split into JSON/scalar fragments.
Null Value Representation *Null Value Representationempty string
  • the string 'null'
  • empty string
Indicates the desired representation of JSON Path expressions resulting in a null value.
Max String Length *Max String Length20 MBThe maximum allowed length of a string value when parsing the JSON document

Dynamic Properties

This component does not support dynamic properties.

Relationships

NameDescription
failureIf a FlowFile fails processing for any reason (for example, the FlowFile is not valid JSON or the specified path does not exist), it will be routed to this relationship
originalThe original FlowFile that was split into segments. If the FlowFile fails processing, nothing will be sent to this relationship
splitAll segments of the original FlowFile will be routed to this relationship

Reads Attributes

This processor does not read attributes.

Writes Attributes

NameDescription
fragment.countThe number of split FlowFiles generated from the parent FlowFile
fragment.identifierAll split FlowFiles produced from the same parent FlowFile will have the same randomly generated UUID added for this attribute
fragment.indexA one-up number that indicates the ordering of the split FlowFiles that were created from a single parent FlowFile
segment.original.filenameThe filename of the parent FlowFile

State Management

This component does not store state.

Restricted

This component is not restricted.

Input Requirement

This component requires an incoming relationship.

System Resource Considerations

ScopeDescription
MEMORYThe entirety of the FlowFile's content (as a JsonNode object) is read into memory, in addition to all of the generated FlowFiles representing the split JSON. If many splits are generated due to the size of the JSON, or how the JSON is configured to be split, a two-phase approach may be necessary to avoid excessive use of memory.

See Also