Class JacksonJsonpParser

java.lang.Object
co.elastic.clients.json.jackson.JacksonJsonpParser
All Implemented Interfaces:
BufferingJsonParser, LookAheadJsonParser, jakarta.json.stream.JsonParser, Closeable, AutoCloseable

public class JacksonJsonpParser extends Object implements LookAheadJsonParser, BufferingJsonParser
A JSONP parser implementation on top of Jackson.

Warning: this implementation isn't fully compliant with the JSONP specification: calling hasNext() moves forward the underlying Jackson parser as Jackson doesn't provide an equivalent method. This means no value getter method (e.g. getInt() or getString() should be called until the next call to next(). Such calls will throw an IllegalStateException.

  • Constructor Details

    • JacksonJsonpParser

      public JacksonJsonpParser(com.fasterxml.jackson.core.JsonParser parser, JacksonJsonpMapper mapper)
  • Method Details

    • jacksonParser

      public com.fasterxml.jackson.core.JsonParser jacksonParser()
      Returns the underlying Jackson parser.
    • hasNext

      public boolean hasNext()
      Specified by:
      hasNext in interface jakarta.json.stream.JsonParser
    • next

      public jakarta.json.stream.JsonParser.Event next()
      Specified by:
      next in interface jakarta.json.stream.JsonParser
    • getString

      public String getString()
      Specified by:
      getString in interface jakarta.json.stream.JsonParser
    • isIntegralNumber

      public boolean isIntegralNumber()
      Specified by:
      isIntegralNumber in interface jakarta.json.stream.JsonParser
    • getInt

      public int getInt()
      Specified by:
      getInt in interface jakarta.json.stream.JsonParser
    • getLong

      public long getLong()
      Specified by:
      getLong in interface jakarta.json.stream.JsonParser
    • getBigDecimal

      public BigDecimal getBigDecimal()
      Specified by:
      getBigDecimal in interface jakarta.json.stream.JsonParser
    • getLocation

      public jakarta.json.stream.JsonLocation getLocation()
      Specified by:
      getLocation in interface jakarta.json.stream.JsonParser
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface jakarta.json.stream.JsonParser
    • getObject

      public jakarta.json.JsonObject getObject()
      Specified by:
      getObject in interface jakarta.json.stream.JsonParser
    • getArray

      public jakarta.json.JsonArray getArray()
      Specified by:
      getArray in interface jakarta.json.stream.JsonParser
    • getValue

      public jakarta.json.JsonValue getValue()
      Specified by:
      getValue in interface jakarta.json.stream.JsonParser
    • skipObject

      public void skipObject()
      Specified by:
      skipObject in interface jakarta.json.stream.JsonParser
    • skipArray

      public void skipArray()
      Specified by:
      skipArray in interface jakarta.json.stream.JsonParser
    • getObjectStream

      public Stream<Map.Entry<String,jakarta.json.JsonValue>> getObjectStream()
      Specified by:
      getObjectStream in interface jakarta.json.stream.JsonParser
    • getArrayStream

      public Stream<jakarta.json.JsonValue> getArrayStream()
      Specified by:
      getArrayStream in interface jakarta.json.stream.JsonParser
    • getValueStream

      public Stream<jakarta.json.JsonValue> getValueStream()
      Not implemented.
      Specified by:
      getValueStream in interface jakarta.json.stream.JsonParser
    • lookAheadFieldValue

      public Map.Entry<String,jakarta.json.stream.JsonParser> lookAheadFieldValue(String name, String defaultValue)
      Description copied from interface: LookAheadJsonParser
      Look ahead the value of a text property in the JSON stream. The parser must be on the START_OBJECT event.
      Specified by:
      lookAheadFieldValue in interface LookAheadJsonParser
      Parameters:
      name - the field name to look up.
      defaultValue - default value if the field is not found.
      Returns:
      a pair containing the field value (or null if not found), and a parser to be used to read the JSON object.
    • findVariant

      public <Variant> Map.Entry<Variant,jakarta.json.stream.JsonParser> findVariant(Map<String,Variant> variants)
      Description copied from interface: LookAheadJsonParser
      In union types, find the variant to be used by looking up property names in the JSON stream until we find one that uniquely identifies the variant.
      Specified by:
      findVariant in interface LookAheadJsonParser
      Type Parameters:
      Variant - the type of variant descriptors used by the caller.
      Parameters:
      variants - a map of variant descriptors, keyed by the property name that uniquely identifies the variant.
      Returns:
      a pair containing the variant descriptor (or null if not found), and a parser to be used to read the JSON object.
    • getJsonData

      public JsonData getJsonData()
      Description copied from interface: BufferingJsonParser
      Get the value at the current parser position as a JsonData object.
      Specified by:
      getJsonData in interface BufferingJsonParser
      Returns: