public interface JsonReader
JsonReader interface.
| Modifier and Type | Method and Description |
|---|---|
void |
beginArray()
Consumes the next token from the JSON stream and asserts that it is the
beginning of a new array.
|
void |
beginObject()
Consumes the next token from the JSON stream and asserts that it is the
beginning of a new object.
|
void |
close()
Closes this JSON reader and the underlying
Reader. |
void |
endArray()
Consumes the next token from the JSON stream and asserts that it is the
end of the current array.
|
void |
endObject()
Consumes the next token from the JSON stream and asserts that it is the
end of the current object.
|
int |
getColumnNumber()
getColumnNumber
|
String |
getInput()
getInput
|
int |
getLineNumber()
getLineNumber
|
boolean |
hasNext()
Returns true if the current array or object has another element.
|
boolean |
nextBoolean()
Returns the
boolean value of the next token,
consuming it. |
double |
nextDouble()
Returns the
double value of the next token,
consuming it. |
int |
nextInt()
Returns the
int value of the next token,
consuming it. |
long |
nextLong()
Returns the
long value of the next token,
consuming it. |
String |
nextName()
Returns the next token, a
property name, and
consumes it. |
void |
nextNull()
Consumes the next token from the JSON stream and asserts that it is a
literal null.
|
Number |
nextNumber()
Returns the
Number value of the next token, consuming it. |
String |
nextString()
Returns the
string value of the next token,
consuming it. |
String |
nextValue()
Reads the next value recursively and returns it as a String.
|
JsonToken |
peek()
Returns the type of the next token without consuming it.
|
void |
setLenient(boolean lenient)
Configure this parser to be be liberal in what it accepts.
|
void |
skipValue()
Skips the next value recursively.
|
void setLenient(boolean lenient)
")]}'\n".
NaNs or 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 ,.
lenient - a boolean.void beginArray()
void endArray()
void beginObject()
void endObject()
boolean hasNext()
JsonToken peek()
JsonToken object.String nextName()
property name, and
consumes it.String object.String nextString()
string value of the next token,
consuming it. If the next token is a number, this method will return its
string form.String object.IllegalStateException - if the next token is not a string or if
this reader is closed.boolean nextBoolean()
boolean value of the next token,
consuming it.IllegalStateException - if the next token is not a boolean or if
this reader is closed.void nextNull()
IllegalStateException - if the next token is not null or if this
reader is closed.double nextDouble()
double value of the next token,
consuming it. If the next token is a string, this method will attempt to
parse it as a double using Double.parseDouble(String).IllegalStateException - if the next token is not a literal value.NumberFormatException - if the next literal value cannot be parsed
as a double, or is non-finite.long nextLong()
long value of the next token,
consuming it. If the next token is a string, this method will attempt to
parse it as a long. If the next token's numeric value cannot be exactly
represented by a Java long, this method throws.IllegalStateException - if the next token is not a literal value.NumberFormatException - if the next literal value cannot be parsed
as a number, or exactly represented as a long.int nextInt()
int value of the next token,
consuming it. If the next token is a string, this method will attempt to
parse it as an int. If the next token's numeric value cannot be exactly
represented by a Java int, this method throws.IllegalStateException - if the next token is not a literal value.NumberFormatException - if the next literal value cannot be parsed
as a number, or exactly represented as an int.void close()
Reader.void skipValue()
String nextValue()
String object.int getLineNumber()
getLineNumber
int getColumnNumber()
getColumnNumber
Number nextNumber()
Number value of the next token, consuming it.
This method will attempt to return the best matching number.
For non-decimal number, if it fits into an int, an int is returned,
else a long else a BigInteger.
For decimal number, a double is returned.
If the next token's numeric value cannot be exactly represented by a Java Number, this method throws.Number object.IllegalStateException - if the next token is not a number.NumberFormatException - if the next value cannot be parsed as a number.Copyright © 2019. All rights reserved.