Skip to main content

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

flatten, json, unflatten

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
Separatorflatten-json-separator.The separator character used for joining keys. Must be a JSON-legal character.

Supports Expression Language, using FlowFile attributes and Environment variables.
Flatten Mode *flatten-modekeep arrays
  • normal
  • keep arrays
  • dot notation
  • keep primitive arrays
Specifies how json should be flattened/unflattened
Ignore Reserved Characters *ignore-reserved-charactersfalse
  • true
  • false
If true, reserved characters in keys will be ignored
Return Type *flatten-json-return-typeflatten
  • flatten
  • unflatten
Specifies the desired return type of json such as flatten/unflatten
Character Set *flatten-json-character-setUTF-8The Character Set in which file is encoded
Pretty Print JSON *flatten-json-pretty-print-jsonfalse
  • true
  • false
Specifies whether or not resulted json should be pretty printed

Dynamic Properties

This component does not support dynamic properties.

Relationships

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

Reads Attributes

This processor does not read attributes.

Writes Attributes

This processor does not write attributes.

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

This component does not specify system resource considerations.

See Also