Package org.apache.nifi.json
Class JsonTreeReader
java.lang.Object
org.apache.nifi.components.AbstractConfigurableComponent
org.apache.nifi.controller.AbstractControllerService
org.apache.nifi.serialization.SchemaRegistryService
org.apache.nifi.json.JsonTreeReader
- All Implemented Interfaces:
org.apache.nifi.components.ConfigurableComponent
,org.apache.nifi.controller.ControllerService
,RecordReaderFactory
- Direct Known Subclasses:
YamlTreeReader
@Tags({"json","tree","record","reader","parser"})
@CapabilityDescription("Parses JSON into individual Record objects. 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. If the schema that is configured contains a field that is not present in the JSON, a null value will be used. If the JSON contains a field that is not present in the schema, that field will be skipped. See the Usage of the Controller Service for more information and examples.")
@SeeAlso(JsonPathReader.class)
public class JsonTreeReader
extends SchemaRegistryService
implements RecordReaderFactory
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
protected String
static final org.apache.nifi.components.PropertyDescriptor
protected SchemaApplicationStrategy
static final org.apache.nifi.components.PropertyDescriptor
static final org.apache.nifi.components.PropertyDescriptor
protected String
protected StartingFieldStrategy
protected com.fasterxml.jackson.core.StreamReadConstraints
protected String
protected String
Fields inherited from class org.apache.nifi.serialization.SchemaRegistryService
schemaAccessStrategy
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected com.fasterxml.jackson.core.StreamReadConstraints
buildStreamReadConstraints
(org.apache.nifi.controller.ConfigurationContext context) Build Stream Read Constraints based on available propertiesprotected RecordSourceFactory
<com.fasterxml.jackson.databind.JsonNode> protected JsonTreeRowRecordReader
createJsonTreeRowRecordReader
(InputStream in, org.apache.nifi.logging.ComponentLog logger, RecordSchema schema) createRecordReader
(Map<String, String> variables, InputStream in, long inputLength, org.apache.nifi.logging.ComponentLog logger) protected org.apache.nifi.components.AllowableValue
protected SchemaAccessStrategy
getSchemaAccessStrategy
(String schemaAccessStrategy, SchemaRegistry schemaRegistry, org.apache.nifi.context.PropertyContext context) protected List
<org.apache.nifi.components.AllowableValue> protected List
<org.apache.nifi.components.PropertyDescriptor> protected boolean
isAllowCommentsEnabled
(org.apache.nifi.controller.ConfigurationContext context) Determine whether to allow comments when parsing based on available propertiesvoid
storePropertyValues
(org.apache.nifi.controller.ConfigurationContext context) Methods inherited from class org.apache.nifi.serialization.SchemaRegistryService
buildStrategyProperty, customValidate, 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, getSupportedDynamicPropertyDescriptor, 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
-
startingFieldName
-
startingFieldStrategy
-
schemaApplicationStrategy
-
streamReadConstraints
protected volatile com.fasterxml.jackson.core.StreamReadConstraints streamReadConstraints -
allowComments
private volatile boolean allowComments -
STARTING_FIELD_STRATEGY
public static final org.apache.nifi.components.PropertyDescriptor STARTING_FIELD_STRATEGY -
STARTING_FIELD_NAME
public static final org.apache.nifi.components.PropertyDescriptor STARTING_FIELD_NAME -
SCHEMA_APPLICATION_STRATEGY
public static final org.apache.nifi.components.PropertyDescriptor SCHEMA_APPLICATION_STRATEGY
-
-
Constructor Details
-
JsonTreeReader
public JsonTreeReader()
-
-
Method Details
-
getSupportedPropertyDescriptors
- Overrides:
getSupportedPropertyDescriptors
in classSchemaRegistryService
-
storePropertyValues
@OnEnabled public void storePropertyValues(org.apache.nifi.controller.ConfigurationContext context) -
buildStreamReadConstraints
protected com.fasterxml.jackson.core.StreamReadConstraints buildStreamReadConstraints(org.apache.nifi.controller.ConfigurationContext context) Build Stream Read Constraints based on available properties- Parameters:
context
- Configuration Context with property values- Returns:
- Stream Read Constraints
-
isAllowCommentsEnabled
protected boolean isAllowCommentsEnabled(org.apache.nifi.controller.ConfigurationContext context) Determine whether to allow comments when parsing based on available properties- Parameters:
context
- Configuration Context with property values- Returns:
- Allow comments status
-
getSchemaAccessStrategyValues
- Overrides:
getSchemaAccessStrategyValues
in classSchemaRegistryService
-
getSchemaAccessStrategy
protected SchemaAccessStrategy getSchemaAccessStrategy(String schemaAccessStrategy, SchemaRegistry schemaRegistry, org.apache.nifi.context.PropertyContext context) - Overrides:
getSchemaAccessStrategy
in classSchemaRegistryService
-
createJsonRecordSourceFactory
protected RecordSourceFactory<com.fasterxml.jackson.databind.JsonNode> createJsonRecordSourceFactory() -
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
-
createJsonTreeRowRecordReader
protected JsonTreeRowRecordReader createJsonTreeRowRecordReader(InputStream in, org.apache.nifi.logging.ComponentLog logger, RecordSchema schema) throws IOException, MalformedRecordException - Throws:
IOException
MalformedRecordException
-