FlattenJson

Description:

Provides the user with the ability to take a nested JSON document and flatten it into a simple key/value pair document. The keys are combined at each level with a user-defined separator that defaults to '.'. This Processor also allows to unflatten back the flattened json. It supports four kinds of flatten mode such as normal, keep-arrays, dot notation for MongoDB query and keep-primitive-arrays. Default flatten mode is 'keep-arrays'.

Tags:

json, flatten, unflatten

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, and whether a property supports the NiFi Expression Language.

NameDefault ValueAllowable ValuesDescription
Separator.The separator character used for joining keys. Must be a JSON-legal character.
Supports Expression Language: true (will be evaluated using flow file attributes and variable registry)
Flatten Modekeep arrays
  • normal Flattens every objects into a single level json
  • keep arrays Flattens every objects and keep arrays format
  • dot notation Conforms to MongoDB dot notation to update also nested documents
  • keep primitive arrays Flattens every objects except arrays which contain only primitive types (strings, numbers, booleans and null)
Specifies how json should be flattened/unflattened
Ignore Reserved Charactersfalse
  • true
  • false
If true, reserved characters in keys will be ignored
Return Typeflatten
  • flatten
  • unflatten
Specifies the desired return type of json such as flatten/unflatten
Character SetUTF-8The Character Set in which file is encoded
Pretty Print JSONfalse
  • true
  • false
Specifies whether or not resulted json should be pretty printed

Relationships:

NameDescription
successSuccessfully flattened/unflattened files go to this relationship.
failureFiles that cannot be flattened/unflattened go to this relationship.

Reads Attributes:

None specified.

Writes Attributes:

None specified.

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:

None specified.