public abstract class JsonReader
extends java.lang.Object
implements java.io.Closeable
| Modifier and Type | Class and Description |
|---|---|
static class |
JsonReader.Token
A structure, name, or value type in a JSON-encoded string.
|
| Modifier and Type | Method and Description |
|---|---|
abstract void |
beginArray()
Consumes the next token from the JSON stream and asserts that it is the beginning of a new
array.
|
abstract void |
beginObject()
Consumes the next token from the JSON stream and asserts that it is the beginning of a new
object.
|
abstract void |
endArray()
Consumes the next token from the JSON stream and asserts that it is the
end of the current array.
|
abstract void |
endObject()
Consumes the next token from the JSON stream and asserts that it is the end of the current
object.
|
abstract boolean |
failOnUnknown()
Returns true if this parser forbids skipping values.
|
abstract java.lang.String |
getPath()
Returns a JsonPath to
the current location in the JSON value.
|
abstract boolean |
hasNext()
Returns true if the current array or object has another element.
|
abstract boolean |
isLenient()
Returns true if this parser is liberal in what it accepts.
|
abstract boolean |
nextBoolean()
Returns the boolean value of the next token, consuming it.
|
abstract double |
nextDouble()
Returns the double value of the next token, consuming it.
|
abstract int |
nextInt()
Returns the int value of the next token, consuming it.
|
abstract long |
nextLong()
Returns the long value of the next token, consuming it.
|
abstract java.lang.String |
nextName()
Returns the next token, a property name, and consumes it.
|
abstract <T> T |
nextNull()
Consumes the next token from the JSON stream and asserts that it is a literal null.
|
abstract java.lang.String |
nextString()
Returns the string value of the next token, consuming it.
|
abstract JsonReader.Token |
peek()
Returns the type of the next token without consuming it.
|
abstract void |
setFailOnUnknown(boolean failOnUnknown)
Configure whether this parser throws a
JsonDataException when skipValue() is
called. |
abstract void |
setLenient(boolean lenient)
Configure this parser to be liberal in what it accepts.
|
abstract void |
skipValue()
Skips the next value recursively.
|
public abstract void setLenient(boolean lenient)
infinities.
// or # and
ending with a newline character.
/* and ending with
*/. Such comments may not be nested.
'single quoted'.
'single quoted'.
; instead of ,.
= or => instead of
:.
; instead of ,.
public abstract boolean isLenient()
public abstract void setFailOnUnknown(boolean failOnUnknown)
JsonDataException when skipValue() is
called. By default this parser permits values to be skipped.
Forbid skipping to prevent unrecognized values from being silently ignored. This option is useful in development and debugging because it means a typo like "locatiom" will be detected early. It's potentially harmful in production because it complicates revising a JSON schema.
public abstract boolean failOnUnknown()
public abstract void beginArray()
throws java.io.IOException
java.io.IOExceptionpublic abstract void endArray()
throws java.io.IOException
java.io.IOExceptionpublic abstract void beginObject()
throws java.io.IOException
java.io.IOExceptionpublic abstract void endObject()
throws java.io.IOException
java.io.IOExceptionpublic abstract boolean hasNext()
throws java.io.IOException
java.io.IOExceptionpublic abstract JsonReader.Token peek() throws java.io.IOException
java.io.IOExceptionpublic abstract java.lang.String nextName()
throws java.io.IOException
JsonDataException - if the next token in the stream is not a property name.java.io.IOExceptionpublic abstract java.lang.String nextString()
throws java.io.IOException
JsonDataException - if the next token is not a string or if this reader is closed.java.io.IOExceptionpublic abstract boolean nextBoolean()
throws java.io.IOException
JsonDataException - if the next token is not a boolean or if this reader is closed.java.io.IOExceptionpublic abstract <T> T nextNull()
throws java.io.IOException
JsonDataException - if the next token is not null or if this reader is closed.java.io.IOExceptionpublic abstract double nextDouble()
throws java.io.IOException
Double.parseDouble(String).JsonDataException - if the next token is not a literal value, or if the next literal
value cannot be parsed as a double, or is non-finite.java.io.IOExceptionpublic abstract long nextLong()
throws java.io.IOException
long, this method throws.JsonDataException - if the next token is not a literal value, if the next literal value
cannot be parsed as a number, or exactly represented as a long.java.io.IOExceptionpublic abstract int nextInt()
throws java.io.IOException
int, this method throws.JsonDataException - if the next token is not a literal value, if the next literal value
cannot be parsed as a number, or exactly represented as an int.java.io.IOExceptionpublic abstract void skipValue()
throws java.io.IOException
This throws a JsonDataException if this parser has been configured to fail on unknown values.
java.io.IOExceptionpublic abstract java.lang.String getPath()