Class JSONReader

java.lang.Object
com.fasterxml.jackson.jr.ob.impl.JSONReader

public class JSONReader extends Object
Root-level helper object that handles initial delegation to actual readers (which are ValueReaders), but does not handle any of reading itself (despite name).

Life-cycle is such that initial instance (called blueprint) is constructed first (including possible configuration using mutant factory methods). This blueprint object acts as a factory, and is never used for direct reading; instead, per-call instance is created by calling perOperationInstance(int, com.fasterxml.jackson.jr.ob.impl.ValueReaderLocator, com.fasterxml.jackson.core.TreeCodec, com.fasterxml.jackson.core.JsonParser).

  • Field Details

    • _mapBuilder

      protected final MapBuilder _mapBuilder
      Handler that takes care of constructing Maps as needed
    • _collectionBuilder

      protected final CollectionBuilder _collectionBuilder
      Handler that takes care of constructing Maps as needed
    • _features

      protected final int _features
    • _treeCodec

      protected final com.fasterxml.jackson.core.TreeCodec _treeCodec
      Configured TreeCodec that is needed if values of type TreeNode are to be read.
    • _readerLocator

      protected final ValueReaderLocator _readerLocator
      Object that is used to find value readers dynamically.
    • _parser

      protected final com.fasterxml.jackson.core.JsonParser _parser
      Parser used by this reader instance.
    • _setterBuffer

      protected final Object[] _setterBuffer
      Minor performance optimization: Object[1] reused to avoid Reflection having to allocate it for every "setter" call.
      Since:
      2.13
  • Constructor Details

    • JSONReader

      public JSONReader(CollectionBuilder lb, MapBuilder mb)
      Constructor used for creating the blueprint instances.
    • JSONReader

      protected JSONReader(JSONReader base, int features, ValueReaderLocator loc, com.fasterxml.jackson.core.TreeCodec tc, com.fasterxml.jackson.core.JsonParser p)
      Constructor used for per-operation (non-blueprint) instance.
  • Method Details

    • withCacheCheck

      public JSONReader withCacheCheck(int features)
    • with

      public JSONReader with(MapBuilder mb)
    • with

      public JSONReader with(CollectionBuilder lb)
    • _with

      protected JSONReader _with(CollectionBuilder lb, MapBuilder mb)
      Overridable method that all mutant factories call if a new instance is to be constructed
    • perOperationInstance

      public JSONReader perOperationInstance(int features, ValueReaderLocator loc, com.fasterxml.jackson.core.TreeCodec tc, com.fasterxml.jackson.core.JsonParser p)
    • arraysAsLists

      public boolean arraysAsLists()
      Since:
      2.8
    • isEnabled

      public boolean isEnabled(JSON.Feature f)
      Since:
      2.11
    • features

      public int features()
      Since:
      2.13
    • readValue

      public Object readValue() throws IOException
      Method for reading a "simple" Object of type indicated by JSON content: Map for JSON Object, Map for JSON Array (or, Object[] if so configured), String for JSON String value and so on.
      Throws:
      IOException
    • readMap

      public Map<String,Object> readMap() throws IOException
      Method for reading a JSON Object from input and building a Map out of it. Note that if input does NOT contain a JSON Object, JSONObjectException will be thrown.
      Throws:
      IOException
    • readList

      public List<Object> readList() throws IOException
      Method for reading a JSON Array from input and building a List out of it. Note that if input does NOT contain a JSON Array, JSONObjectException will be thrown.
      Throws:
      IOException
    • readArray

      public Object[] readArray() throws IOException
      Method for reading a JSON Array from input and building a Object[] out of it. Note that if input does NOT contain a JSON Array, JSONObjectException will be thrown.
      Throws:
      IOException
    • readBean

      public <T> T readBean(Class<T> type) throws IOException
      Method for reading a JSON Object from input and building a Bean of specified type out of it; Bean has to conform to standard Java Bean specification by having setters for passing JSON Object properties.
      Throws:
      IOException
    • readArrayOf

      public <T> T[] readArrayOf(Class<T> type) throws IOException
      Throws:
      IOException
    • readListOf

      public <T> List<T> readListOf(Class<T> type) throws IOException
      Method for reading a JSON Array from input and building a List out of it, binding values into specified type. Note that if input does NOT contain a JSON Array, JSONObjectException will be thrown.
      Throws:
      IOException
    • readMapOf

      public <T> Map<String,T> readMapOf(Class<T> type) throws IOException
      Method for reading a JSON Object from input and building a Map out of it, binding values into specified type. Note that if input does NOT contain a JSON Object, JSONObjectException will be thrown.
      Throws:
      IOException
      Since:
      2.10
    • readTree

      public com.fasterxml.jackson.core.TreeNode readTree() throws IOException
      Throws:
      IOException
      Since:
      2.11
    • _mapBuilder

      protected MapBuilder _mapBuilder(Class<?> mapType)
    • _collectionBuilder

      protected CollectionBuilder _collectionBuilder(Class<?> collType)