Class JsonReader


public class JsonReader extends XmlReader
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).
  • Constructor Details

    • JsonReader

      public JsonReader(File file)
    • JsonReader

      public JsonReader(Reader reader)
  • Method Details

    • isUseBigDecimal

      public boolean isUseBigDecimal()
      Indicates if decimal numbers are read as BigDecimal instead of Double (default is false).
    • useBigDecimal

      @Deprecated public JsonReader useBigDecimal(boolean useBigDecimal)
      Deprecated.
      Use setUseBigDecimal(boolean) method instead.
    • setUseBigDecimal

      public JsonReader setUseBigDecimal(boolean useBigDecimal)
      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

      public JsonReader setUseBigInteger(boolean useBigInteger)
      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

      public JsonReader setAutoCloseReader(boolean autoCloseReader)
      Description copied from class: XmlReader
      Indicates if the Reader passed to the constructor is closed when this reader closes (default is true); a file opened by this reader is always closed.
      Overrides:
      setAutoCloseReader in class XmlReader
    • setDebug

      public JsonReader setDebug(boolean debug)
      Description copied from class: XmlReader
      Indicates if each node read is logged at debug level (default is false).
      Overrides:
      setDebug in class XmlReader
    • setAddTextToParent

      public JsonReader setAddTextToParent(boolean addTextToParent)
      Description copied from class: XmlReader
      Indicates if each child node's text should be concatenated to its parent during parsing (defaults to false). Setting this to true will result in higher memory consumption.
      Overrides:
      setAddTextToParent in class XmlReader
    • addRecordBreak

      public JsonReader addRecordBreak(String locationPathAsString)
      Description copied from class: XmlReader
      Adds a location path (for example //book); a record is completed each time a matching element ends.
      Overrides:
      addRecordBreak in class XmlReader
    • addField

      public JsonReader addField(XmlField field)
      Overrides:
      addField in class XmlReader
    • addField

      public JsonReader addField(String name, String locationPathAsString, boolean cascadeValues)
      Description copied from class: XmlReader
      Identifies a new field using XPath in the XML stream.
      Overrides:
      addField in class XmlReader
      Parameters:
      name - the field name to create
      locationPathAsString - the XPath to match to populate this field
      cascadeValues - indicates if this reader should return the last value seen for this field when no matches are available.
    • addField

      public JsonReader addField(String name, String locationPathAsString, String cascadeResetLocationPath)
      Description copied from class: XmlReader
      Identifies a new field using XPath in the XML stream. If cascadeResetLocationPath is 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.
      Overrides:
      addField in class XmlReader
      Parameters:
      name - the field name to create
      locationPathAsString - the XPath to match to populate this field
      cascadeResetLocationPath - the XPath to identify when cascading values (i.e. the last value seen for this field) should be cleared.
    • addField

      public JsonReader addField(String name, String locationPathAsString)
      Description copied from class: XmlReader
      Identifies a new field using XPath in the XML stream.
      Overrides:
      addField in class XmlReader
      Parameters:
      name - the field name to create
      locationPathAsString - the XPath to match to populate this field
    • setDuplicateFieldPolicy

      public JsonReader setDuplicateFieldPolicy(XmlReader.DuplicateFieldPolicy duplicateFieldPolicy)
      Description copied from class: XmlReader
      Sets how a field matched more than once in a record is handled; null restores the default XmlReader.DuplicateFieldPolicy.USE_LAST_VALUE.
      Overrides:
      setDuplicateFieldPolicy in class XmlReader
    • setIgnoreNamespaces

      public JsonReader setIgnoreNamespaces(boolean ignoreNamespaces)
      Description copied from class: XmlReader
      Indicates if namespaces on elements and attributes are ignored when matching expressions (default to true).
      Overrides:
      setIgnoreNamespaces in class XmlReader
    • setSaveLineage

      public JsonReader setSaveLineage(boolean saveLineage)
      Description copied from class: DataReader
      Indicates if record and field lineage is captured for each record read (default is false); enabling it throws if DataReader.isLineageSupported() is false or the product edition does not include lineage.
      Overrides:
      setSaveLineage in class XmlReader
    • setDescription

      public JsonReader setDescription(String description)
      Description copied from class: Endpoint
      Sets the optional text shown for this endpoint in Endpoint.toString() and exception properties.
      Overrides:
      setDescription in class XmlReader
    • addLineage

      protected Record addLineage(Record record)
      Description copied from class: DataReader
      Called by DataReader.read() for each record from DataReader.readImpl() while lineage is saved; the default copies recordLineage into every field along with its original index and name. Overrides set their source details on recordLineage first and end with super.addLineage(record).
      Overrides:
      addLineage in class XmlReader
    • addExceptionProperties

      public DataException addExceptionProperties(DataException exception)
      Description copied from class: Endpoint
      Adds this endpoint's current state to a DataException. Since this method is called whenever an exception is thrown, subclasses should override it to add their specific information.
      Overrides:
      addExceptionProperties in class XmlReader