Skip to main content

AttributesToJSON

Description

Generates a JSON representation of the input FlowFile Attributes. The resulting JSON can be written to either a new Attribute 'JSONAttributes' or written to the FlowFile as content. Attributes which contain nested JSON objects can either be handled as JSON or as escaped JSON depending on the strategy chosen.

Tags

attributes, flowfile, json

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
Attributes ListAttributes ListComma separated list of attributes to be included in the resulting JSON. If this value is left empty then all existing Attributes will be included. This list of attributes is case sensitive. If an attribute specified in the list is not found it will be be emitted to the resulting JSON with an empty string or NULL value.
Attributes Regular Expressionattributes-to-json-regexRegular expression that will be evaluated against the flow file attributes to select the matching attributes. This property can be used in combination with the attributes list property.

Supports Expression Language, using Environment variables.
Destination *Destinationflowfile-attribute
  • flowfile-attribute
  • flowfile-content
Control if JSON value is written as a new flowfile attribute 'JSONAttributes' or written in the flowfile content. Writing to flowfile content will overwrite any existing flowfile content.
Include Core Attributes *Include Core Attributestrue
  • true
  • false
Determines if the FlowFile org.apache.nifi.flowfile.attributes.CoreAttributes which are contained in every FlowFile should be included in the final JSON value generated.
Null Value *Null Valuefalse
  • true
  • false
If true a non existing selected attribute will be NULL in the resulting JSON. If false an empty string will be placed in the JSON
JSON Handling Strategy *JSON Handling StrategyEscaped
  • Escaped
  • Nested
Strategy to use for handling attributes which contain nested JSON.
Pretty Print *Pretty Printfalse
  • true
  • false
Apply pretty print formatting to the output.

This property is only considered if:
  • the property Destination has a value of flowfile-content

Dynamic Properties

This component does not support dynamic properties.

Relationships

NameDescription
failureFailed to convert attributes to JSON
successSuccessfully converted attributes to JSON

Reads Attributes

This processor does not read attributes.

Writes Attributes

NameDescription
JSONAttributesJSON representation of 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