Package org.apache.nifi.json
Class JsonTreeReader
- All Implemented Interfaces:
ConfigurableComponent
,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 PropertyDescriptor
protected SchemaApplicationStrategy
static final PropertyDescriptor
static final PropertyDescriptor
protected String
protected StartingFieldStrategy
private 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
Build Stream Read Constraints based on available propertiesprotected RecordSourceFactory
<com.fasterxml.jackson.databind.JsonNode> protected JsonTreeRowRecordReader
createJsonTreeRowRecordReader
(InputStream in, ComponentLog logger, RecordSchema schema) createRecordReader
(Map<String, String> variables, InputStream in, long inputLength, ComponentLog logger) protected AllowableValue
protected SchemaAccessStrategy
getSchemaAccessStrategy
(String schemaAccessStrategy, SchemaRegistry schemaRegistry, PropertyContext context) protected List
<AllowableValue> protected List
<PropertyDescriptor> protected boolean
Determine whether to allow comments when parsing based on available propertiesvoid
storePropertyValues
(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
-
allowComments
private volatile boolean allowComments -
streamReadConstraints
private volatile com.fasterxml.jackson.core.StreamReadConstraints streamReadConstraints -
STARTING_FIELD_STRATEGY
-
STARTING_FIELD_NAME
-
SCHEMA_APPLICATION_STRATEGY
-
-
Constructor Details
-
JsonTreeReader
public JsonTreeReader()
-
-
Method Details
-
getSupportedPropertyDescriptors
- Overrides:
getSupportedPropertyDescriptors
in classSchemaRegistryService
-
storePropertyValues
-
buildStreamReadConstraints
protected com.fasterxml.jackson.core.StreamReadConstraints buildStreamReadConstraints(ConfigurationContext context) Build Stream Read Constraints based on available properties- Parameters:
context
- Configuration Context with property values- Returns:
- Stream Read Constraints
-
isAllowCommentsEnabled
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, PropertyContext context) - Overrides:
getSchemaAccessStrategy
in classSchemaRegistryService
-
createJsonRecordSourceFactory
protected RecordSourceFactory<com.fasterxml.jackson.databind.JsonNode> createJsonRecordSourceFactory() -
getDefaultSchemaAccessStrategy
- Overrides:
getDefaultSchemaAccessStrategy
in classSchemaRegistryService
-
createRecordReader
public RecordReader createRecordReader(Map<String, String> variables, InputStream in, long inputLength, ComponentLog logger) throws IOException, MalformedRecordException, SchemaNotFoundException- Specified by:
createRecordReader
in interfaceRecordReaderFactory
- Throws:
IOException
MalformedRecordException
SchemaNotFoundException
-
createJsonTreeRowRecordReader
protected JsonTreeRowRecordReader createJsonTreeRowRecordReader(InputStream in, ComponentLog logger, RecordSchema schema) throws IOException, MalformedRecordException - Throws:
IOException
MalformedRecordException
-