Package org.apache.nifi.json
Class JsonPathReader
java.lang.Object
org.apache.nifi.components.AbstractConfigurableComponent
org.apache.nifi.controller.AbstractControllerService
org.apache.nifi.serialization.SchemaRegistryService
org.apache.nifi.json.JsonPathReader
- All Implemented Interfaces:
org.apache.nifi.components.ConfigurableComponent
,org.apache.nifi.controller.ControllerService
,RecordReaderFactory
@Tags({"json","jsonpath","record","reader","parser"})
@CapabilityDescription("Parses JSON records and evaluates user-defined JSON Path\'s against each JSON object. While the reader expects each record to be well-formed JSON, the content of a FlowFile may consist of many records, each as a well-formed JSON array or JSON object with optional whitespace between them, such as the common \'JSON-per-line\' format. If an array is encountered, each element in that array will be treated as a separate record. User-defined properties define the fields that should be extracted from the JSON in order to form the fields of a Record. Any JSON field that is not extracted via a JSONPath will not be returned in the JSON Records.")
@SeeAlso(JsonTreeReader.class)
@DynamicProperty(name="The field name for the record.",
value="A JSONPath Expression that will be evaluated against each JSON record. The result of the JSONPath will be the value of the field whose name is the same as the property name.",
description="User-defined properties identify how to extract specific fields from a JSON object in order to create a Record",
expressionLanguageScope=NONE)
public class JsonPathReader
extends SchemaRegistryService
implements RecordReaderFactory
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
private String
private LinkedHashMap
<String, com.jayway.jsonpath.JsonPath> private com.fasterxml.jackson.core.StreamReadConstraints
private String
private String
Fields inherited from class org.apache.nifi.serialization.SchemaRegistryService
schemaAccessStrategy
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
compileJsonPaths
(org.apache.nifi.controller.ConfigurationContext context) createRecordReader
(Map<String, String> variables, InputStream in, long inputLength, org.apache.nifi.logging.ComponentLog logger) protected Collection
<org.apache.nifi.components.ValidationResult> customValidate
(org.apache.nifi.components.ValidationContext validationContext) protected org.apache.nifi.components.AllowableValue
protected SchemaAccessStrategy
getSchemaAccessStrategy
(String strategy, SchemaRegistry schemaRegistry, org.apache.nifi.context.PropertyContext context) protected List
<org.apache.nifi.components.AllowableValue> protected org.apache.nifi.components.PropertyDescriptor
getSupportedDynamicPropertyDescriptor
(String propertyDescriptorName) protected List
<org.apache.nifi.components.PropertyDescriptor> Methods inherited from class org.apache.nifi.serialization.SchemaRegistryService
buildStrategyProperty, getConfigurationContext, getSchema, getSchema, getSchemaAccessStrategy, getSchemaAccessStrategyDescriptor, getSuppliedSchemaFields, migrateProperties, storeSchemaAccessStrategy
Methods inherited from class org.apache.nifi.controller.AbstractControllerService
abstractClearConfigContext, abstractStoreConfigContext, disabled, enabled, getControllerServiceLookup, getIdentifier, getLogger, getNodeTypeProvider, getProperty, getStateManager, init, initialize, isEnabled
Methods inherited from class org.apache.nifi.components.AbstractConfigurableComponent
equals, getPropertyDescriptor, getPropertyDescriptors, hashCode, onPropertyModified, toString, validate
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.nifi.components.ConfigurableComponent
getIdentifier, getPropertyDescriptor, getPropertyDescriptors, onPropertyModified, validate
Methods inherited from interface org.apache.nifi.controller.ControllerService
initialize, isStateful, migrateProperties
Methods inherited from interface org.apache.nifi.serialization.RecordReaderFactory
createRecordReader
-
Field Details
-
dateFormat
-
timeFormat
-
timestampFormat
-
jsonPaths
-
allowComments
private volatile boolean allowComments -
streamReadConstraints
private volatile com.fasterxml.jackson.core.StreamReadConstraints streamReadConstraints
-
-
Constructor Details
-
JsonPathReader
public JsonPathReader()
-
-
Method Details
-
getSupportedPropertyDescriptors
- Overrides:
getSupportedPropertyDescriptors
in classSchemaRegistryService
-
getSupportedDynamicPropertyDescriptor
protected org.apache.nifi.components.PropertyDescriptor getSupportedDynamicPropertyDescriptor(String propertyDescriptorName) - Overrides:
getSupportedDynamicPropertyDescriptor
in classorg.apache.nifi.components.AbstractConfigurableComponent
-
compileJsonPaths
@OnEnabled public void compileJsonPaths(org.apache.nifi.controller.ConfigurationContext context) -
customValidate
protected Collection<org.apache.nifi.components.ValidationResult> customValidate(org.apache.nifi.components.ValidationContext validationContext) - Overrides:
customValidate
in classSchemaRegistryService
-
getSchemaAccessStrategyValues
- Overrides:
getSchemaAccessStrategyValues
in classSchemaRegistryService
-
getSchemaAccessStrategy
protected SchemaAccessStrategy getSchemaAccessStrategy(String strategy, SchemaRegistry schemaRegistry, org.apache.nifi.context.PropertyContext context) - Overrides:
getSchemaAccessStrategy
in classSchemaRegistryService
-
getDefaultSchemaAccessStrategy
protected org.apache.nifi.components.AllowableValue getDefaultSchemaAccessStrategy()- Overrides:
getDefaultSchemaAccessStrategy
in classSchemaRegistryService
-
createRecordReader
public RecordReader createRecordReader(Map<String, String> variables, InputStream in, long inputLength, org.apache.nifi.logging.ComponentLog logger) throws IOException, MalformedRecordException, SchemaNotFoundException- Specified by:
createRecordReader
in interfaceRecordReaderFactory
- Throws:
IOException
MalformedRecordException
SchemaNotFoundException
-