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, split, jsonpath

Properties:

In the list below, the names of required properties appear in bold. Any other properties (not in bold) are considered optional. The table also indicates any default values.

Name Default Value Allowable Values Description
JsonPath Expression A JsonPath expression that indicates the array element to split into JSON/scalar fragments.
Null Value Representation empty string * the string 'null'
* empty string
Indicates the desired representation of JSON Path expressions resulting in a null value.

Relationships:

Name Description
original The original FlowFile that was split into segments. If the FlowFile fails processing, nothing will be sent to this relationship
failure If 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
split All segments of the original FlowFile will be routed to this relationship

Reads Attributes:

None specified.

Writes Attributes:

None specified.

How to configure?

Step 1: Drag and drop the SplitJson processor to canvas.

Step 2: Double click the processor to configure, the configuration dialog will be opened as follows,

properties

Step 3: Check the usage of each property and update required values.

Properties and usage

JsonPath Expression: Used to split the JSON array into JSON/scalar fragments using JsonPath expression.

Null Value Representation: It is used to indicate that the given JSON Path expressions are resulting in a null value.

Flat Json Array

For example, if you want to split JSON array into JSON elements you have to update JsonPath expression as $.[*] if it is flat JSON.

sample

Nested Json

  • For example, if you have nested JSON as follows and you want to retrieve all the JSON objects inside the store object you can use $.store.*as JsonPath Expression.
{ "store": { "book": [ { "category": "reference", "author": "Nigel Rees", "title": "Sayings of the Century", "price": 8.95 } ], "bicycle": { "color": "red", "price": 19.95 } } }