Package co.elastic.clients.json.jackson
Class JacksonJsonpParser
java.lang.Object
co.elastic.clients.json.jackson.JacksonJsonpParser
- All Implemented Interfaces:
BufferingJsonParser
,LookAheadJsonParser
,jakarta.json.stream.JsonParser
,Closeable
,AutoCloseable
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
.
-
Nested Class Summary
Nested classes/interfaces inherited from interface jakarta.json.stream.JsonParser
jakarta.json.stream.JsonParser.Event
-
Constructor Summary
ConstructorDescriptionJacksonJsonpParser
(com.fasterxml.jackson.core.JsonParser parser, JacksonJsonpMapper mapper) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
<Variant> Map.Entry<Variant,
jakarta.json.stream.JsonParser> findVariant
(Map<String, Variant> variants) 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.jakarta.json.JsonArray
getArray()
Stream<jakarta.json.JsonValue>
int
getInt()
Get the value at the current parser position as aJsonData
object.jakarta.json.stream.JsonLocation
long
getLong()
jakarta.json.JsonObject
jakarta.json.JsonValue
getValue()
Stream<jakarta.json.JsonValue>
Not implemented.boolean
hasNext()
boolean
com.fasterxml.jackson.core.JsonParser
Returns the underlying Jackson parser.lookAheadFieldValue
(String name, String defaultValue) Look ahead the value of a text property in the JSON stream.jakarta.json.stream.JsonParser.Event
next()
void
void
-
Constructor Details
-
JacksonJsonpParser
-
-
Method Details
-
jacksonParser
public com.fasterxml.jackson.core.JsonParser jacksonParser()Returns the underlying Jackson parser. -
hasNext
public boolean hasNext()- Specified by:
hasNext
in interfacejakarta.json.stream.JsonParser
-
next
public jakarta.json.stream.JsonParser.Event next()- Specified by:
next
in interfacejakarta.json.stream.JsonParser
-
getString
- Specified by:
getString
in interfacejakarta.json.stream.JsonParser
-
isIntegralNumber
public boolean isIntegralNumber()- Specified by:
isIntegralNumber
in interfacejakarta.json.stream.JsonParser
-
getInt
public int getInt()- Specified by:
getInt
in interfacejakarta.json.stream.JsonParser
-
getLong
public long getLong()- Specified by:
getLong
in interfacejakarta.json.stream.JsonParser
-
getBigDecimal
- Specified by:
getBigDecimal
in interfacejakarta.json.stream.JsonParser
-
getLocation
public jakarta.json.stream.JsonLocation getLocation()- Specified by:
getLocation
in interfacejakarta.json.stream.JsonParser
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfacejakarta.json.stream.JsonParser
-
getObject
public jakarta.json.JsonObject getObject()- Specified by:
getObject
in interfacejakarta.json.stream.JsonParser
-
getArray
public jakarta.json.JsonArray getArray()- Specified by:
getArray
in interfacejakarta.json.stream.JsonParser
-
getValue
public jakarta.json.JsonValue getValue()- Specified by:
getValue
in interfacejakarta.json.stream.JsonParser
-
skipObject
public void skipObject()- Specified by:
skipObject
in interfacejakarta.json.stream.JsonParser
-
skipArray
public void skipArray()- Specified by:
skipArray
in interfacejakarta.json.stream.JsonParser
-
getObjectStream
- Specified by:
getObjectStream
in interfacejakarta.json.stream.JsonParser
-
getArrayStream
- Specified by:
getArrayStream
in interfacejakarta.json.stream.JsonParser
-
getValueStream
Not implemented.- Specified by:
getValueStream
in interfacejakarta.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 theSTART_OBJECT
event.- Specified by:
lookAheadFieldValue
in interfaceLookAheadJsonParser
- 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 interfaceLookAheadJsonParser
- 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
Description copied from interface:BufferingJsonParser
Get the value at the current parser position as aJsonData
object.- Specified by:
getJsonData
in interfaceBufferingJsonParser
- Returns:
-