Class AttributesToJSON
java.lang.Object
org.apache.nifi.components.AbstractConfigurableComponent
org.apache.nifi.processor.AbstractSessionFactoryProcessor
org.apache.nifi.processor.AbstractProcessor
org.apache.nifi.processors.standard.AttributesToJSON
- All Implemented Interfaces:
org.apache.nifi.components.ConfigurableComponent,org.apache.nifi.processor.Processor
@SideEffectFree
@SupportsBatching
@Tags({"json","attributes","flowfile"})
@InputRequirement(INPUT_REQUIRED)
@CapabilityDescription("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.")
@WritesAttribute(attribute="JSONAttributes",
description="JSON representation of Attributes")
public class AttributesToJSON
extends org.apache.nifi.processor.AbstractProcessor
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringprivate static final Stringstatic final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.PropertyDescriptorstatic final Stringstatic final Stringprivate booleanstatic final org.apache.nifi.components.PropertyDescriptorstatic final Stringstatic final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.PropertyDescriptorprivate Booleanprivate static final com.fasterxml.jackson.databind.ObjectMapperprivate com.fasterxml.jackson.databind.ObjectWriterprivate Patternstatic final org.apache.nifi.components.PropertyDescriptorprivate static final List<org.apache.nifi.components.PropertyDescriptor> static final org.apache.nifi.processor.Relationshipstatic final org.apache.nifi.processor.Relationshipprivate static final Set<org.apache.nifi.processor.Relationship> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuildAttributesMapForFlowFile(org.apache.nifi.flowfile.FlowFile ff, Set<String> attributes, Set<String> attributesToRemove, boolean nullValForEmptyString, Pattern attPattern) Builds the Map of attributes that should be included in the JSON that is emitted from this process.getFormattedAttributes(Map<String, Object> flowFileAttributes) Set<org.apache.nifi.processor.Relationship> protected List<org.apache.nifi.components.PropertyDescriptor> private booleanisPossibleJsonArray(String value) private booleanisPossibleJsonObject(String value) voidonScheduled(org.apache.nifi.processor.ProcessContext context) voidonTrigger(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.processor.ProcessSession session) Methods inherited from class org.apache.nifi.processor.AbstractProcessor
onTriggerMethods inherited from class org.apache.nifi.processor.AbstractSessionFactoryProcessor
getControllerServiceLookup, getIdentifier, getLogger, getNodeTypeProvider, init, initialize, isConfigurationRestored, isScheduled, toString, updateConfiguredRestoredTrue, updateScheduledFalse, updateScheduledTrueMethods inherited from class org.apache.nifi.components.AbstractConfigurableComponent
customValidate, equals, getPropertyDescriptor, getPropertyDescriptors, getSupportedDynamicPropertyDescriptor, hashCode, onPropertyModified, validateMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.nifi.components.ConfigurableComponent
getPropertyDescriptor, getPropertyDescriptors, onPropertyModified, validateMethods inherited from interface org.apache.nifi.processor.Processor
isStateful, migrateProperties, migrateRelationships
-
Field Details
-
JSON_ATTRIBUTE_NAME
- See Also:
-
AT_LIST_SEPARATOR
- See Also:
-
DESTINATION_ATTRIBUTE
- See Also:
-
DESTINATION_CONTENT
- See Also:
-
APPLICATION_JSON
- See Also:
-
ATTRIBUTES_LIST
public static final org.apache.nifi.components.PropertyDescriptor ATTRIBUTES_LIST -
ATTRIBUTES_REGEX
public static final org.apache.nifi.components.PropertyDescriptor ATTRIBUTES_REGEX -
DESTINATION
public static final org.apache.nifi.components.PropertyDescriptor DESTINATION -
INCLUDE_CORE_ATTRIBUTES
public static final org.apache.nifi.components.PropertyDescriptor INCLUDE_CORE_ATTRIBUTES -
NULL_VALUE_FOR_EMPTY_STRING
public static final org.apache.nifi.components.PropertyDescriptor NULL_VALUE_FOR_EMPTY_STRING -
JSON_HANDLING_STRATEGY
public static final org.apache.nifi.components.PropertyDescriptor JSON_HANDLING_STRATEGY -
PRETTY_PRINT
public static final org.apache.nifi.components.PropertyDescriptor PRETTY_PRINT -
PROPERTY_DESCRIPTORS
-
REL_SUCCESS
public static final org.apache.nifi.processor.Relationship REL_SUCCESS -
REL_FAILURE
public static final org.apache.nifi.processor.Relationship REL_FAILURE -
RELATIONSHIPS
-
OBJECT_MAPPER
private static final com.fasterxml.jackson.databind.ObjectMapper OBJECT_MAPPER -
attributesToRemove
-
attributes
-
nullValueForEmptyString
-
destinationContent
private volatile boolean destinationContent -
objectWriter
private volatile com.fasterxml.jackson.databind.ObjectWriter objectWriter -
pattern
-
jsonHandlingStrategy
-
-
Constructor Details
-
AttributesToJSON
public AttributesToJSON()
-
-
Method Details
-
getSupportedPropertyDescriptors
- Overrides:
getSupportedPropertyDescriptorsin classorg.apache.nifi.components.AbstractConfigurableComponent
-
getRelationships
- Specified by:
getRelationshipsin interfaceorg.apache.nifi.processor.Processor- Overrides:
getRelationshipsin classorg.apache.nifi.processor.AbstractSessionFactoryProcessor
-
buildAttributesMapForFlowFile
protected Map<String,Object> buildAttributesMapForFlowFile(org.apache.nifi.flowfile.FlowFile ff, Set<String> attributes, Set<String> attributesToRemove, boolean nullValForEmptyString, Pattern attPattern) Builds the Map of attributes that should be included in the JSON that is emitted from this process.- Returns:
- Map of values that are feed to a Jackson ObjectMapper
-
buildAtrs
-
onScheduled
@OnScheduled public void onScheduled(org.apache.nifi.processor.ProcessContext context) -
onTrigger
public void onTrigger(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.processor.ProcessSession session) throws org.apache.nifi.processor.exception.ProcessException - Specified by:
onTriggerin classorg.apache.nifi.processor.AbstractProcessor- Throws:
org.apache.nifi.processor.exception.ProcessException
-
getFormattedAttributes
private Map<String,Object> getFormattedAttributes(Map<String, Object> flowFileAttributes) throws com.fasterxml.jackson.core.JsonProcessingException- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
isPossibleJsonArray
-
isPossibleJsonObject
-