@Tags(value={"json","jsonpath","record","reader","parser"}) @CapabilityDescription(value="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(value=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
Modifier and Type | Field and Description |
---|---|
private String |
dateFormat |
private LinkedHashMap<String,com.jayway.jsonpath.JsonPath> |
jsonPaths |
private String |
timeFormat |
private String |
timestampFormat |
schemaAccessStrategy
Constructor and Description |
---|
JsonPathReader() |
Modifier and Type | Method and Description |
---|---|
void |
compileJsonPaths(ConfigurationContext context) |
RecordReader |
createRecordReader(Map<String,String> variables,
InputStream in,
long inputLength,
ComponentLog logger) |
protected Collection<ValidationResult> |
customValidate(ValidationContext validationContext) |
protected AllowableValue |
getDefaultSchemaAccessStrategy() |
protected SchemaAccessStrategy |
getSchemaAccessStrategy(String strategy,
SchemaRegistry schemaRegistry,
PropertyContext context) |
protected List<AllowableValue> |
getSchemaAccessStrategyValues() |
protected PropertyDescriptor |
getSupportedDynamicPropertyDescriptor(String propertyDescriptorName) |
protected List<PropertyDescriptor> |
getSupportedPropertyDescriptors() |
buildStrategyProperty, getConfigurationContext, getSchema, getSchema, getSchemaAccessStrategy, getSchemaAcessStrategyDescriptor, getSuppliedSchemaFields, storeSchemaAccessStrategy
abstractClearConfigContext, abstractStoreConfigContext, disabled, enabled, getControllerServiceLookup, getIdentifier, getLogger, getNodeTypeProvider, getProperty, getStateManager, init, initialize, isEnabled
equals, getPropertyDescriptor, getPropertyDescriptors, hashCode, onPropertyModified, toString, validate
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
createRecordReader
initialize
getIdentifier, getPropertyDescriptor, getPropertyDescriptors, onPropertyModified, validate
private volatile String dateFormat
private volatile String timeFormat
private volatile String timestampFormat
private volatile LinkedHashMap<String,com.jayway.jsonpath.JsonPath> jsonPaths
protected List<PropertyDescriptor> getSupportedPropertyDescriptors()
getSupportedPropertyDescriptors
in class SchemaRegistryService
protected PropertyDescriptor getSupportedDynamicPropertyDescriptor(String propertyDescriptorName)
getSupportedDynamicPropertyDescriptor
in class AbstractConfigurableComponent
@OnEnabled public void compileJsonPaths(ConfigurationContext context)
protected Collection<ValidationResult> customValidate(ValidationContext validationContext)
customValidate
in class SchemaRegistryService
protected List<AllowableValue> getSchemaAccessStrategyValues()
getSchemaAccessStrategyValues
in class SchemaRegistryService
protected SchemaAccessStrategy getSchemaAccessStrategy(String strategy, SchemaRegistry schemaRegistry, PropertyContext context)
getSchemaAccessStrategy
in class SchemaRegistryService
protected AllowableValue getDefaultSchemaAccessStrategy()
getDefaultSchemaAccessStrategy
in class SchemaRegistryService
public RecordReader createRecordReader(Map<String,String> variables, InputStream in, long inputLength, ComponentLog logger) throws IOException, MalformedRecordException, SchemaNotFoundException
createRecordReader
in interface RecordReaderFactory
IOException
MalformedRecordException
SchemaNotFoundException
Copyright © 2021 Apache NiFi Project. All rights reserved.