Package io.avaje.json
Interface JsonReader
- All Superinterfaces:
AutoCloseable,Closeable
Reads json content as a stream of JSON tokens and content.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumA structure, name, or value type in a JSON-encoded string. -
Method Summary
Modifier and TypeMethodDescriptionvoidRead array begin.voidRead begin object.voidbeginObject(PropertyNames names) Set the current property names.default voidRead the beginning of an ARRAY or x-json-stream (new line delimited json content).voidclose()Close the resources of the reader.Return the current Token.voidendArray()Read array end.voidRead end object.default voidRead the end of an ARRAY or x-json-stream (new line delimited json content).booleanReturn true if there is a next element in an ARRAY.booleanReturn true if there is a next field to be read in an OBJECT.default booleanReturn true if there is a next element in an ARRAY or x-json-stream (new line delimited json content).booleanReturn true if the value to be read is a null.location()Return the current location.Return the next field.Read and return the next value as a BigInteger.byte[]Read and return the binary value from base64.booleanRead and return the next value as a boolean.Read and return the next value as a BigDecimal.doubleRead and return the next value as a double.intreadInt()Read and return the next value as an int.longreadLong()Read and return the next value as a long.readRaw()Read and return raw json content as a String.Read and return the next value as String.voidSkip the next value.default JsonReaderstreamArray(boolean streamArray) Explicitly state if the streaming content contains ARRAY '[' and ']' tokens.voidunmappedField(String fieldName) Reading json with an unmapped field, throw an Exception if failOnUnmapped is true.<T> TUnwrap and return the underlying JsonParser.
-
Method Details
-
unwrap
Unwrap and return the underlying JsonParser.When using avaje-jsonb-jackson this will return the underlying Jackson JsonParser.
// when using avaje-jsonb-jackson var jacksonParser = jsonReader.unwrap(JsonParser.class); -
beginStream
Read the beginning of an ARRAY or x-json-stream (new line delimited json content). -
endStream
Read the end of an ARRAY or x-json-stream (new line delimited json content). -
hasNextStreamElement
Return true if there is a next element in an ARRAY or x-json-stream (new line delimited json content).Effectively this allows for new line delimited rather than commas between array elements.
-
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
Set the current property names.Can be used by the reader to optimize the reading of known names.
-
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
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
Read and return the next value as a BigDecimal. -
readBigInteger
Read and return the next value as a BigInteger. -
readString
Read and return the next value as String. -
readBinary
byte[] readBinary()Read and return the binary value from base64. -
readRaw
Read and return raw json content as a String. -
location
Return the current location. This is typically used when reporting errors. -
currentToken
Return the current Token. -
close
void close()Close the resources of the reader.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
skipValue
void skipValue()Skip the next value. -
unmappedField
Reading json with an unmapped field, throw an Exception if failOnUnmapped is true. -
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.
-