TContext - context passed to deserialized object instancespublic final class JsonReader<TContext> extends Object
JsonReader can be reused by calling process methods.
| Modifier and Type | Class and Description |
|---|---|
static interface |
JsonReader.BindObject<T>
Existing instances can be provided as target for deserialization.
|
static class |
JsonReader.DoublePrecision |
static class |
JsonReader.ErrorInfo |
static interface |
JsonReader.ReadJsonObject<T extends JsonObject> |
static interface |
JsonReader.ReadObject<T>
Custom objects can be deserialized based on the implementation specified through this interface.
|
static class |
JsonReader.UnknownNumberParsing |
| Modifier and Type | Field and Description |
|---|---|
protected byte[] |
buffer |
protected char[] |
chars |
TContext |
context |
protected int |
doubleLengthLimit |
protected JsonReader.DoublePrecision |
doublePrecision |
protected JsonReader.ErrorInfo |
errorInfo |
protected int |
maxNumberDigits |
protected JsonReader.UnknownNumberParsing |
unknownNumbers |
| Modifier and Type | Method and Description |
|---|---|
StringBuffer |
appendString(StringBuffer buffer) |
StringBuilder |
appendString(StringBuilder builder) |
int |
calcHash() |
int |
calcWeakHash() |
void |
checkArrayEnd()
Check if the last read token is an array end
|
void |
checkObjectEnd()
Check if the last read token is an object end
|
void |
comma()
Will advance to next token and check if it's comma
|
<T extends JsonObject> |
deserializeCollection(JsonReader.ReadJsonObject<T> readObject) |
<T extends JsonObject> |
deserializeCollection(JsonReader.ReadJsonObject<T> readObject,
Collection<T> res) |
<T,S extends T> |
deserializeCollection(JsonReader.ReadObject<S> readObject) |
<T,S extends T> |
deserializeCollection(JsonReader.ReadObject<S> readObject,
Collection<T> res) |
<T extends JsonObject> |
deserializeNullableCollection(JsonReader.ReadJsonObject<T> readObject) |
<T extends JsonObject> |
deserializeNullableCollection(JsonReader.ReadJsonObject<T> readObject,
Collection<T> res) |
<T,S extends T> |
deserializeNullableCollection(JsonReader.ReadObject<S> readObject) |
<T,S extends T> |
deserializeNullableCollection(JsonReader.ReadObject<S> readObject,
Collection<T> res) |
void |
endArray()
Will advance to next token and check if it's array end
|
void |
endObject()
Will advance to next token and check it it's object end
|
int |
fillName() |
int |
fillNameWeakHash() |
int |
getCurrentIndex() |
int |
getLastHash() |
String |
getLastName() |
byte |
getNextToken()
Read next token (byte) from input JSON.
|
int |
getTokenStart() |
<T extends JsonObject> |
iterateOver(JsonReader.ReadJsonObject<T> reader) |
<T> Iterator<T> |
iterateOver(JsonReader.ReadObject<T> reader) |
byte |
last()
Which was last byte read from the JSON input.
|
int |
length()
Valid length of the input buffer.
|
ParsingException |
newParseError(String description) |
ParsingException |
newParseError(String description,
int positionOffset) |
ParsingException |
newParseErrorAt(String description,
int positionOffset) |
ParsingException |
newParseErrorAt(String description,
int positionOffset,
Exception cause) |
ParsingException |
newParseErrorFormat(String shortDescription,
int positionOffset,
String longDescriptionFormat,
Object... arguments) |
ParsingException |
newParseErrorWith(String shortDescription,
int positionOffset,
String longDescriptionPrefix,
String longDescriptionMessage,
Object argument,
String longDescriptionSuffix) |
ParsingException |
newParseErrorWith(String description,
Object argument) |
<T> T |
next(Class<T> manifest)
Will advance to next token and read the JSON into specified type
|
<T> T |
next(Class<T> manifest,
T instance)
Will advance to next token and bind the JSON to provided instance
|
<T> T |
next(JsonReader.BindObject<T> binder,
T instance)
Will advance to next token and bind the JSON to provided instance
|
<T> T |
next(JsonReader.ReadObject<T> reader)
Will advance to next token and read the JSON into specified type
|
String |
positionDescription() |
String |
positionDescription(int offset) |
long |
positionInStream() |
long |
positionInStream(int offset) |
JsonReader<TContext> |
process(byte[] newBuffer,
int newLength)
Bind byte[] buffer for processing.
|
JsonReader<TContext> |
process(InputStream stream)
Bind input stream for processing.
|
byte |
read()
Read next byte from the JSON input.
|
<T> T[] |
readArray(JsonReader.ReadObject<T> readObject,
T[] emptyArray) |
byte[] |
readBase64() |
<T> ArrayList<T> |
readCollection(JsonReader.ReadObject<T> readObject) |
String |
readKey()
Read key value of JSON input.
|
<K,V> LinkedHashMap<K,V> |
readMap(JsonReader.ReadObject<K> readKey,
JsonReader.ReadObject<V> readValue) |
String |
readNext()
Deprecated.
|
char[] |
readNumber()
Deprecated.
|
<T> LinkedHashSet<T> |
readSet(JsonReader.ReadObject<T> readObject) |
char[] |
readSimpleQuote()
Read simple "ascii string" into temporary buffer.
|
String |
readSimpleString()
Read simple ascii string.
|
String |
readString()
Read string from JSON input.
|
void |
reset(InputStream stream)
Deprecated.
|
int |
scanNumber() |
void |
semicolon()
Will advance to next token and check if it's semicolon
|
byte |
skip()
Skip to next non-whitespace token (byte)
Will not allocate memory while skipping over JSON input.
|
void |
startArray()
Will advance to next token and check if it's array start
|
void |
startAttribute(String name) |
void |
startObject()
Will advance to next token and check if it's object start
|
String |
toString() |
boolean |
wasFalse()
Checks if 'false' value is at current position.
|
boolean |
wasLastName(byte[] name) |
boolean |
wasLastName(String name) |
boolean |
wasNull()
Checks if 'null' value is at current position.
|
boolean |
wasTrue()
Checks if 'true' value is at current position.
|
public final TContext context
protected byte[] buffer
protected char[] chars
protected final JsonReader.ErrorInfo errorInfo
protected final JsonReader.DoublePrecision doublePrecision
protected final int doubleLengthLimit
protected final JsonReader.UnknownNumberParsing unknownNumbers
protected final int maxNumberDigits
@Deprecated public final void reset(InputStream stream) throws IOException
stream - process streamIOException - error reading from streampublic final JsonReader<TContext> process(@Nullable InputStream stream) throws IOException
stream - set input streamIOException - unable to read from streampublic final JsonReader<TContext> process(@Nullable byte[] newBuffer, int newLength)
newBuffer - new buffer to use for processingnewLength - length of buffer which can be usedpublic final int length()
public final byte read()
throws IOException
IOException - when end of JSON inputpublic final byte last()
public String positionDescription()
public String positionDescription(int offset)
public final ParsingException newParseError(String description)
public final ParsingException newParseError(String description, int positionOffset)
public final ParsingException newParseErrorAt(String description, int positionOffset)
public final ParsingException newParseErrorAt(String description, int positionOffset, Exception cause)
public final ParsingException newParseErrorFormat(String shortDescription, int positionOffset, String longDescriptionFormat, Object... arguments)
public final ParsingException newParseErrorWith(String description, @Nullable Object argument)
public final ParsingException newParseErrorWith(String shortDescription, int positionOffset, String longDescriptionPrefix, String longDescriptionMessage, @Nullable Object argument, String longDescriptionSuffix)
public final int getTokenStart()
public final int getCurrentIndex()
@Deprecated public final char[] readNumber()
public final int scanNumber()
public final String readSimpleString() throws ParsingException
ParsingException - unable to parse stringpublic final char[] readSimpleQuote()
throws ParsingException
ParsingException - unable to parse stringpublic final String readString() throws IOException
String value must start and end with a double quote (").
IOException - error reading string inputpublic final StringBuilder appendString(StringBuilder builder) throws IOException
IOExceptionpublic final StringBuffer appendString(StringBuffer buffer) throws IOException
IOExceptionpublic final byte getNextToken()
throws IOException
IOException - unable to get next byte (end of stream, ...)public final long positionInStream()
public final long positionInStream(int offset)
public final int fillName()
throws IOException
IOExceptionpublic final int fillNameWeakHash()
throws IOException
IOExceptionpublic final int calcHash()
throws IOException
IOExceptionpublic final int calcWeakHash()
throws IOException
IOExceptionpublic final int getLastHash()
public final boolean wasLastName(String name)
public final boolean wasLastName(byte[] name)
public final String getLastName() throws IOException
IOExceptionpublic final byte skip()
throws IOException
IOException - unable to read next byte (end of stream, invalid JSON, ...)@Deprecated public String readNext() throws IOException
IOException - throws if invalid JSON detectedpublic final byte[] readBase64()
throws IOException
IOExceptionpublic final String readKey() throws IOException
IOException - unable to parse string inputpublic final boolean wasNull()
throws ParsingException
ParsingException - invalid 'null' value detectedpublic final boolean wasTrue()
throws ParsingException
ParsingException - invalid 'true' value detectedpublic final boolean wasFalse()
throws ParsingException
ParsingException - invalid 'false' value detectedpublic final void comma()
throws IOException
IOException - it's not commapublic final void semicolon()
throws IOException
IOException - it's not semicolonpublic final void startArray()
throws IOException
IOException - it's not array startpublic final void endArray()
throws IOException
IOException - it's not array endpublic final void startObject()
throws IOException
IOException - it's not object startpublic final void endObject()
throws IOException
IOException - it's not object endpublic final void startAttribute(String name) throws IOException
IOExceptionpublic final void checkArrayEnd()
throws IOException
IOException - it's not array endpublic final void checkObjectEnd()
throws IOException
IOException - it's not object end@Nullable public final <T> T next(Class<T> manifest) throws IOException
T - typemanifest - type to read intoIOException - unable to process JSON@Nullable public final <T> T next(JsonReader.ReadObject<T> reader) throws IOException
T - typereader - reader to useIOException - unable to process JSON@Nullable public final <T> T next(Class<T> manifest, T instance) throws IOException
T - typemanifest - type to read intoinstance - instance to bindIOException - unable to process JSON@Nullable public final <T> T next(JsonReader.BindObject<T> binder, T instance) throws IOException
T - typebinder - binder to useinstance - instance to bindIOException - unable to process JSON@Nullable public final <T> ArrayList<T> readCollection(JsonReader.ReadObject<T> readObject) throws IOException
IOException@Nullable public final <T> LinkedHashSet<T> readSet(JsonReader.ReadObject<T> readObject) throws IOException
IOException@Nullable public final <K,V> LinkedHashMap<K,V> readMap(JsonReader.ReadObject<K> readKey, JsonReader.ReadObject<V> readValue) throws IOException
IOException@Nullable public final <T> T[] readArray(JsonReader.ReadObject<T> readObject, T[] emptyArray) throws IOException
IOExceptionpublic final <T,S extends T> ArrayList<T> deserializeCollection(JsonReader.ReadObject<S> readObject) throws IOException
IOExceptionpublic final <T,S extends T> void deserializeCollection(JsonReader.ReadObject<S> readObject, Collection<T> res) throws IOException
IOExceptionpublic final <T,S extends T> ArrayList<T> deserializeNullableCollection(JsonReader.ReadObject<S> readObject) throws IOException
IOExceptionpublic final <T,S extends T> void deserializeNullableCollection(JsonReader.ReadObject<S> readObject, Collection<T> res) throws IOException
IOExceptionpublic final <T extends JsonObject> ArrayList<T> deserializeCollection(JsonReader.ReadJsonObject<T> readObject) throws IOException
IOExceptionpublic final <T extends JsonObject> void deserializeCollection(JsonReader.ReadJsonObject<T> readObject, Collection<T> res) throws IOException
IOExceptionpublic final <T extends JsonObject> ArrayList<T> deserializeNullableCollection(JsonReader.ReadJsonObject<T> readObject) throws IOException
IOExceptionpublic final <T extends JsonObject> void deserializeNullableCollection(JsonReader.ReadJsonObject<T> readObject, Collection<T> res) throws IOException
IOExceptionpublic final <T> Iterator<T> iterateOver(JsonReader.ReadObject<T> reader)
public final <T extends JsonObject> Iterator<T> iterateOver(JsonReader.ReadJsonObject<T> reader)
Copyright © 2023. All rights reserved.