Package io.avaje.jsonb
Interface JsonReader
-
- All Superinterfaces:
AutoCloseable
,Closeable
public interface JsonReader extends Closeable
Reads json content as a stream of JSON tokens and content.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
JsonReader.Token
A structure, name, or value type in a JSON-encoded string.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
beginArray()
Read array begin.void
beginObject()
Read begin object.default void
beginStream()
Read the beginning of an ARRAY or x-json-stream (new line delimited json content).void
close()
Close the resources of the reader.JsonReader.Token
currentToken()
Return the current Token.void
endArray()
Read array end.void
endObject()
Read end object.default void
endStream()
Read the end of an ARRAY or x-json-stream (new line delimited json content).boolean
hasNextElement()
Return true if there is a next element in an ARRAY.boolean
hasNextField()
Return true if there is a next field to be read in an OBJECT.boolean
isNullValue()
Return true if the value to be read is a null.String
location()
Return the current location.void
names(PropertyNames names)
Set the current property names.String
nextField()
Return the next field.BigInteger
readBigInteger()
Read and return the next value as a BigInteger.byte[]
readBinary()
Read and return the binary value from base64.boolean
readBoolean()
Read and return the next value as a boolean.BigDecimal
readDecimal()
Read and return the next value as a BigDecimal.double
readDouble()
Read and return the next value as a double.int
readInt()
Read and return the next value as an int.long
readLong()
Read and return the next value as a long.String
readRaw()
Read and return raw json content as a String.String
readString()
Read and return the next value as String.void
skipValue()
Skip the next value.default JsonReader
streamArray(boolean streamArray)
Explicitly state if the streaming content contains ARRAY '[' and ']' tokens.void
unmappedField(String fieldName)
Reading json with an unmapped field, throw an Exception if failOnUnmapped is true.
-
-
-
Method Detail
-
names
void names(PropertyNames names)
Set the current property names.Can be used by the reader to optimise the reading of known names.
-
beginStream
default void beginStream()
Read the beginning of an ARRAY or x-json-stream (new line delimited json content).
-
endStream
default void endStream()
Read the end of an ARRAY or x-json-stream (new line delimited json content).
-
beginArray
void beginArray()
Read array begin.
-
endArray
void endArray()
Read array end.
-
hasNextElement
boolean hasNextElement()
Return true if there is a next element in an ARRAY.
-
beginObject
void beginObject()
Read begin object.
-
endObject
void endObject()
Read end object.
-
hasNextField
boolean hasNextField()
Return true if there is a next field to be read in an OBJECT.
-
nextField
String nextField()
Return the next field.
-
isNullValue
boolean isNullValue()
Return true if the value to be read is a null.
-
readBoolean
boolean readBoolean()
Read and return the next value as a boolean.
-
readInt
int readInt()
Read and return the next value as an int.
-
readLong
long readLong()
Read and return the next value as a long.
-
readDouble
double readDouble()
Read and return the next value as a double.
-
readDecimal
BigDecimal readDecimal()
Read and return the next value as a BigDecimal.
-
readBigInteger
BigInteger readBigInteger()
Read and return the next value as a BigInteger.
-
readString
String readString()
Read and return the next value as String.
-
readBinary
byte[] readBinary()
Read and return the binary value from base64.
-
readRaw
String readRaw()
Read and return raw json content as a String.
-
location
String location()
Return the current location. This is typically used when reporting errors.
-
currentToken
JsonReader.Token currentToken()
Return the current Token.
-
close
void close()
Close the resources of the reader.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
skipValue
void skipValue()
Skip the next value.
-
unmappedField
void unmappedField(String fieldName)
Reading json with an unmapped field, throw an Exception if failOnUnmapped is true.
-
streamArray
default JsonReader streamArray(boolean streamArray)
Explicitly state if the streaming content contains ARRAY '[' and ']' tokens.The builtin avaje-jsonb parser detects this automatically. Effectively we only need to set this when we are using the Jackson core parser.
try (JsonReader reader = jsonb.reader(arrayJson)) { // content contains ARRAY '[' and ']' tokens, use streamArray(true) Stream<MyBasic> asStream = type.stream(reader.streamArray(true)); asStream.forEach(...); }
- Parameters:
streamArray
- When true the content is expected to contain ARRAY '[' and ']' tokens.
-
-