Class EvaluateJsonPath
java.lang.Object
org.apache.nifi.components.AbstractConfigurableComponent
org.apache.nifi.processor.AbstractSessionFactoryProcessor
org.apache.nifi.processor.AbstractProcessor
org.apache.nifi.processors.standard.AbstractJsonPathProcessor
org.apache.nifi.processors.standard.EvaluateJsonPath
- All Implemented Interfaces:
org.apache.nifi.components.ConfigurableComponent,org.apache.nifi.processor.Processor
@SideEffectFree
@SupportsBatching
@Tags({"JSON","evaluate","JsonPath"})
@InputRequirement(INPUT_REQUIRED)
@CapabilityDescription("Evaluates one or more JsonPath expressions against the content of a FlowFile. The results of those expressions are assigned to FlowFile Attributes or are written to the content of the FlowFile itself, depending on configuration of the Processor. JsonPaths are entered by adding user-defined properties; the name of the property maps to the Attribute Name into which the result will be placed (if the Destination is flowfile-attribute; otherwise, the property name is ignored). The value of the property must be a valid JsonPath expression. A Return Type of \'auto-detect\' will make a determination based off the configured destination. When \'Destination\' is set to \'flowfile-attribute,\' a return type of \'scalar\' will be used. When \'Destination\' is set to \'flowfile-content,\' a return type of \'JSON\' will be used.If the JsonPath evaluates to a JSON array or JSON object and the Return Type is set to \'scalar\' the FlowFile will be unmodified and will be routed to failure. A Return Type of JSON can return scalar values if the provided JsonPath evaluates to the specified value and will be routed as a match.If Destination is \'flowfile-content\' and the JsonPath does not evaluate to a defined path, the FlowFile will be routed to \'unmatched\' without having its contents modified. If Destination is \'flowfile-attribute\' and the expression matches nothing, attributes will be created with empty strings as the value unless \'Path Not Found Behaviour\' is set to \'skip\', and the FlowFile will always be routed to \'matched.\'")
@DynamicProperty(name="A FlowFile attribute(if <Destination> is set to \'flowfile-attribute\')",
value="A JsonPath expression",
description="If <Destination>=\'flowfile-attribute\' then that FlowFile attribute will be set to any JSON objects that match the JsonPath. If <Destination>=\'flowfile-content\' then the FlowFile content will be updated to any JSON objects that match the JsonPath.")
public class EvaluateJsonPath
extends AbstractJsonPathProcessor
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.nifi.processors.standard.AbstractJsonPathProcessor
AbstractJsonPathProcessor.JsonPathValidator -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ConcurrentMap<String, com.jayway.jsonpath.JsonPath> static final org.apache.nifi.components.PropertyDescriptorstatic final Stringstatic final Stringprivate booleanprivate com.jayway.jsonpath.Configurationprivate Stringstatic final org.apache.nifi.components.PropertyDescriptorstatic final Stringstatic final Stringstatic final Stringprivate Stringprivate static final List<org.apache.nifi.components.PropertyDescriptor> static final org.apache.nifi.processor.Relationshipstatic final org.apache.nifi.processor.Relationshipstatic final org.apache.nifi.processor.Relationshipprivate static final Set<org.apache.nifi.processor.Relationship> static final org.apache.nifi.components.PropertyDescriptorstatic final Stringstatic final Stringstatic final Stringprivate StringFields inherited from class org.apache.nifi.processors.standard.AbstractJsonPathProcessor
EMPTY_STRING_OPTION, MAX_STRING_LENGTH, NULL_REPRESENTATION_MAP, NULL_STRING_OPTION, NULL_VALUE_DEFAULT_REPRESENTATION -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Collection<org.apache.nifi.components.ValidationResult> customValidate(org.apache.nifi.components.ValidationContext context) Set<org.apache.nifi.processor.Relationship> protected org.apache.nifi.components.PropertyDescriptorgetSupportedDynamicPropertyDescriptor(String propertyDescriptorName) protected List<org.apache.nifi.components.PropertyDescriptor> voidonPropertyModified(org.apache.nifi.components.PropertyDescriptor descriptor, String oldValue, String newValue) voidonRemoved(org.apache.nifi.processor.ProcessContext processContext) Provides cleanup of the map for any JsonPath values that may have been created.voidonScheduled(org.apache.nifi.processor.ProcessContext processContext) voidonTrigger(org.apache.nifi.processor.ProcessContext processContext, org.apache.nifi.processor.ProcessSession processSession) voidMethods inherited from class org.apache.nifi.processors.standard.AbstractJsonPathProcessor
createConfiguration, getResultRepresentation, isJsonScalar, validateAndEstablishJsonContextMethods 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
equals, getPropertyDescriptor, getPropertyDescriptors, hashCode, 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, validateMethods inherited from interface org.apache.nifi.processor.Processor
isStateful, migrateProperties, migrateRelationships
-
Field Details
-
DESTINATION_ATTRIBUTE
- See Also:
-
DESTINATION_CONTENT
- See Also:
-
RETURN_TYPE_AUTO
- See Also:
-
RETURN_TYPE_JSON
- See Also:
-
RETURN_TYPE_SCALAR
- See Also:
-
PATH_NOT_FOUND_IGNORE
- See Also:
-
PATH_NOT_FOUND_WARN
- See Also:
-
PATH_NOT_FOUND_SKIP
- See Also:
-
DESTINATION
public static final org.apache.nifi.components.PropertyDescriptor DESTINATION -
RETURN_TYPE
public static final org.apache.nifi.components.PropertyDescriptor RETURN_TYPE -
PATH_NOT_FOUND
public static final org.apache.nifi.components.PropertyDescriptor PATH_NOT_FOUND -
PROPERTY_DESCRIPTORS
-
REL_MATCH
public static final org.apache.nifi.processor.Relationship REL_MATCH -
REL_NO_MATCH
public static final org.apache.nifi.processor.Relationship REL_NO_MATCH -
REL_FAILURE
public static final org.apache.nifi.processor.Relationship REL_FAILURE -
RELATIONSHIPS
-
cachedJsonPathMap
-
attributeToJsonPathEntrySetQueue
-
destinationIsAttribute
private volatile boolean destinationIsAttribute -
returnType
-
pathNotFound
-
nullDefaultValue
-
jsonPathConfiguration
private volatile com.jayway.jsonpath.Configuration jsonPathConfiguration
-
-
Constructor Details
-
EvaluateJsonPath
public EvaluateJsonPath()
-
-
Method Details
-
customValidate
protected Collection<org.apache.nifi.components.ValidationResult> customValidate(org.apache.nifi.components.ValidationContext context) - Overrides:
customValidatein classorg.apache.nifi.components.AbstractConfigurableComponent
-
getRelationships
- Specified by:
getRelationshipsin interfaceorg.apache.nifi.processor.Processor- Overrides:
getRelationshipsin classorg.apache.nifi.processor.AbstractSessionFactoryProcessor
-
getSupportedPropertyDescriptors
- Overrides:
getSupportedPropertyDescriptorsin classorg.apache.nifi.components.AbstractConfigurableComponent
-
getSupportedDynamicPropertyDescriptor
protected org.apache.nifi.components.PropertyDescriptor getSupportedDynamicPropertyDescriptor(String propertyDescriptorName) - Overrides:
getSupportedDynamicPropertyDescriptorin classorg.apache.nifi.components.AbstractConfigurableComponent
-
onPropertyModified
public void onPropertyModified(org.apache.nifi.components.PropertyDescriptor descriptor, String oldValue, String newValue) - Specified by:
onPropertyModifiedin interfaceorg.apache.nifi.components.ConfigurableComponent- Overrides:
onPropertyModifiedin classorg.apache.nifi.components.AbstractConfigurableComponent
-
onRemoved
@OnRemoved public void onRemoved(org.apache.nifi.processor.ProcessContext processContext) Provides cleanup of the map for any JsonPath values that may have been created. This will remove common values shared between multiple instances, but will be regenerated when the next validation cycle occurs as a result of isStale()- Parameters:
processContext- context
-
onScheduled
@OnScheduled public void onScheduled(org.apache.nifi.processor.ProcessContext processContext) -
onUnscheduled
@OnUnscheduled public void onUnscheduled() -
onTrigger
public void onTrigger(org.apache.nifi.processor.ProcessContext processContext, org.apache.nifi.processor.ProcessSession processSession) throws org.apache.nifi.processor.exception.ProcessException - Specified by:
onTriggerin classorg.apache.nifi.processor.AbstractProcessor- Throws:
org.apache.nifi.processor.exception.ProcessException
-