Class JsonReader
Obtains records from a JSON stream using
XmlReader location paths, where JSON objects and arrays appear
as object and array elements (for example //array/object/name).-
Nested Class Summary
Nested classes/interfaces inherited from class com.northconcepts.datapipeline.xml.XmlReader
XmlReader.DuplicateFieldPolicyNested classes/interfaces inherited from class com.northconcepts.datapipeline.core.DataEndpoint
DataEndpoint.State -
Field Summary
Fields inherited from class com.northconcepts.datapipeline.xml.XmlReader
currentRecord, fields, hasCascadingFields, reader, recordBreaksFields inherited from class com.northconcepts.datapipeline.core.DataReader
fieldLineage, recordLineageFields inherited from class com.northconcepts.datapipeline.core.DataEndpoint
lastRecord, PRODUCT, PRODUCT_VERSION, VENDOR, XML_INPUT_FACTORY_KEYFields inherited from class com.northconcepts.datapipeline.core.Endpoint
BUFFER_SIZE, captureElapsedTime, DEFAULT_READ_BUFFER_SIZEFields inherited from class com.northconcepts.datapipeline.core.DataObject
id, log, name, TIMESTAMP_FORMAT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddExceptionProperties(DataException exception) Adds this endpoint's current state to aDataException.Identifies a new field using XPath in the XML stream.Identifies a new field using XPath in the XML stream.Identifies a new field using XPath in the XML stream.protected RecordaddLineage(Record record) Called byDataReader.read()for each record fromDataReader.readImpl()while lineage is saved; the default copiesrecordLineageinto every field along with its original index and name.addRecordBreak(String locationPathAsString) Adds a location path (for example//book); a record is completed each time a matching element ends.booleanIndicates if decimal numbers are read as BigDecimal instead of Double (default is false).booleanReturns whether BigInteger should be used for reading large numeric values.setAddTextToParent(boolean addTextToParent) Indicates if each child node's text should be concatenated to its parent during parsing (defaults to false).setAutoCloseReader(boolean autoCloseReader) Indicates if theReaderpassed to the constructor is closed when this reader closes (default is true); a file opened by this reader is always closed.setDebug(boolean debug) Indicates if each node read is logged at debug level (default is false).setDescription(String description) Sets the optional text shown for this endpoint inEndpoint.toString()and exception properties.setDuplicateFieldPolicy(XmlReader.DuplicateFieldPolicy duplicateFieldPolicy) Sets how a field matched more than once in a record is handled; null restores the defaultXmlReader.DuplicateFieldPolicy.USE_LAST_VALUE.setIgnoreNamespaces(boolean ignoreNamespaces) Indicates if namespaces on elements and attributes are ignored when matching expressions (default to true).setSaveLineage(boolean saveLineage) Indicates if record and field lineage is captured for each record read (default is false); enabling it throws ifDataReader.isLineageSupported()is false or the product edition does not include lineage.setUseBigDecimal(boolean useBigDecimal) Indicates if decimal numbers are read as BigDecimal instead of Double (default is false).setUseBigInteger(boolean useBigInteger) Sets whether BigInteger should be used for reading large numeric values.useBigDecimal(boolean useBigDecimal) Deprecated.Methods inherited from class com.northconcepts.datapipeline.xml.XmlReader
addFieldValue, close, createRecord, expandAndPushRecords, expandListFieldsAsFields, getDuplicateFieldPolicy, getFieldValues, getXmlNodeReader, isAddTextToParent, isAutoCloseReader, isDebug, isIgnoreNamespaces, isLineageSupported, isRecordBreak, open, readImpl, saveAncestorAttributeFieldValues, saveAncestorNodeFieldValues, saveFieldValues, setRecordFieldMethods inherited from class com.northconcepts.datapipeline.core.DataReader
available, getBufferSize, getNestedEndpoint, getNestedReader, getReader, getRootEndpoint, getRootReader, isExhausted, isSaveLineage, peek, pop, push, read, skipMethods inherited from class com.northconcepts.datapipeline.core.DataEndpoint
decrementRecordCount, enableJmx, getLastRecord, getRecordCount, getRecordCountAsBigInteger, getRecordCountAsString, incrementRecordCount, isRecordCountBigInteger, resetRecordCount, toStringMethods inherited from class com.northconcepts.datapipeline.core.Endpoint
addElapsedtime, assertClosed, assertNotOpened, assertOpened, finalize, getClosedOn, getDescription, getElapsedTime, getElapsedTimeAsString, getOpenedOn, getOpenElapsedTime, getOpenElapsedTimeAsString, getSelfTime, getSelfTimeAsString, getState, isCaptureElapsedTime, isClosed, isOpen, setCaptureElapsedTime
-
Constructor Details
-
JsonReader
-
JsonReader
-
-
Method Details
-
isUseBigDecimal
public boolean isUseBigDecimal()Indicates if decimal numbers are read as BigDecimal instead of Double (default is false). -
useBigDecimal
Deprecated.UsesetUseBigDecimal(boolean)method instead. -
setUseBigDecimal
Indicates if decimal numbers are read as BigDecimal instead of Double (default is false). -
isUseBigInteger
public boolean isUseBigInteger()Returns whether BigInteger should be used for reading large numeric values. When enabled, integer values are read as BigInteger instead of Long to handle values larger than Long.MAX_VALUE.- Returns:
- true if BigInteger is used for numeric values, false otherwise (default is false)
-
setUseBigInteger
Sets whether BigInteger should be used for reading large numeric values. When enabled, integer values are read as BigInteger instead of Long to handle values larger than Long.MAX_VALUE.- Parameters:
useBigInteger- true to use BigInteger, false to use Long (default is false)- Returns:
- this JsonReader instance for method chaining
-
setAutoCloseReader
Description copied from class:XmlReaderIndicates if theReaderpassed to the constructor is closed when this reader closes (default is true); a file opened by this reader is always closed.- Overrides:
setAutoCloseReaderin classXmlReader
-
setDebug
Description copied from class:XmlReaderIndicates if each node read is logged at debug level (default is false). -
setAddTextToParent
Description copied from class:XmlReaderIndicates if each child node's text should be concatenated to its parent during parsing (defaults to false). Setting this totruewill result in higher memory consumption.- Overrides:
setAddTextToParentin classXmlReader
-
addRecordBreak
Description copied from class:XmlReaderAdds a location path (for example//book); a record is completed each time a matching element ends.- Overrides:
addRecordBreakin classXmlReader
-
addField
-
addField
Description copied from class:XmlReaderIdentifies a new field using XPath in the XML stream. -
addField
public JsonReader addField(String name, String locationPathAsString, String cascadeResetLocationPath) Description copied from class:XmlReaderIdentifies a new field using XPath in the XML stream. IfcascadeResetLocationPathis not null and not empty, it will indicate when this field should be cleared, otherwise this field will return the last value seen when no new matches are available. -
addField
Description copied from class:XmlReaderIdentifies a new field using XPath in the XML stream. -
setDuplicateFieldPolicy
Description copied from class:XmlReaderSets how a field matched more than once in a record is handled; null restores the defaultXmlReader.DuplicateFieldPolicy.USE_LAST_VALUE.- Overrides:
setDuplicateFieldPolicyin classXmlReader
-
setIgnoreNamespaces
Description copied from class:XmlReaderIndicates if namespaces on elements and attributes are ignored when matching expressions (default to true).- Overrides:
setIgnoreNamespacesin classXmlReader
-
setSaveLineage
Description copied from class:DataReaderIndicates if record and field lineage is captured for each record read (default is false); enabling it throws ifDataReader.isLineageSupported()is false or the product edition does not include lineage.- Overrides:
setSaveLineagein classXmlReader
-
setDescription
Description copied from class:EndpointSets the optional text shown for this endpoint inEndpoint.toString()and exception properties.- Overrides:
setDescriptionin classXmlReader
-
addLineage
Description copied from class:DataReaderCalled byDataReader.read()for each record fromDataReader.readImpl()while lineage is saved; the default copiesrecordLineageinto every field along with its original index and name. Overrides set their source details onrecordLineagefirst and end withsuper.addLineage(record).- Overrides:
addLineagein classXmlReader
-
addExceptionProperties
Description copied from class:EndpointAdds this endpoint's current state to aDataException. Since this method is called whenever an exception is thrown, subclasses should override it to add their specific information.- Overrides:
addExceptionPropertiesin classXmlReader
-
setUseBigDecimal(boolean)method instead.