Description and usage of JoltTransformJSON:
Applies a list of Jolt specifications to the flowfile JSON payload. A new FlowFile is created with transformed content and is routed to the ‘success’ relationship. If the JSON transform fails,the original FlowFile is routed to the ‘failure’ relationship.
JSON, jolt, transform, shiftr, chainr, defaultr, removr, cardinality, sort
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, and whether a property supports the Expression Language Guide..
|Name||Default Value||Allowable Values||Description|
|Jolt Transformation DSL||jolt-transform-chain||
|Specifies the Jolt Transformation that should be used with the provided specification.|
|Custom Transformation Class Name||Fully Qualified Class Name for Custom Transformation|
|Custom Module Directory||Comma-separated list of paths to files and/or directories which contain modules containing custom transformations (that are not included on NiFi's classpath)|
Jolt Specification for transform of JSON data. This value is ignored if the Jolt Sort Transformation is selected.
Supports Expression Language: true
|success||The FlowFile with transformed content will be routed to this relationship|
|failure||If a FlowFile fails processing for any reason (for example, the FlowFile is not valid JSON), it will be routed to this relationship|
|mime.type||Always set to application/json|
This component does not store state.
This component is not restricted.
The Jolt utilities processing JSON are not not stream based therefore large JSON document transformation may consume large amounts of memory. Currently UTF-8 FlowFile content and Jolt specifications are supported. A specification can be defined using Expression Language where attributes can be referred either on the left or right hand side within the specification syntax. Custom Jolt Transformations (that implement the Transform interface) are supported. Modules containing custom libraries which do not existing on the current class path can be included via the custom module directory property. Note: When configuring a processor if user selects of the Default transformation yet provides a Chain specification the system does not alert that the specification is invalid and and will produce failed flow files. This is a known issue identified within the Jolt library.
How to configure?
This sample explains how to configure the JoltTransformJSON processor and perform the various transformations on the given input JSON file.
Step 1: Create a JSON file as shown in the following image.
Step 2: Drag and drop the GetFile processor to read the input JSON file content as shown in the following image.
Step 3: Drag and drop the UpdateAttribute processor for specifying the spec JSON content required for the Jolt transformations.
The operations such as shift, remove, sort, cardinality, remove, modify, and even custom transformations can also be performed on the input JSON data.
Step 4: Drag and drop the JoltTransformJSON processor into the canvas and mention the spec attribute on the Jolt Specification property.
Step 5: Drag and drop the PutFile processor into the canvas to save the transformed JSON data.
The result of the shift operation from the location to counterTop is shown in the following image.