Class JsonTreeReader
java.lang.Object
com.google.gson.stream.JsonReader
com.google.gson.internal.bind.JsonTreeReader
- All Implemented Interfaces:
Closeable, AutoCloseable
This reader walks the elements of a JsonElement as if it was coming from a
character stream.
- Author:
- Jesse Wilson
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidConsumes the next token from the JSON stream and asserts that it is the beginning of a new array.voidConsumes the next token from the JSON stream and asserts that it is the beginning of a new object.voidclose()Closes this JSON reader and the underlyingReader.voidendArray()Consumes the next token from the JSON stream and asserts that it is the end of the current array.voidConsumes the next token from the JSON stream and asserts that it is the end of the current object.getPath()Returns a JsonPath to the current location in the JSON value.booleanhasNext()Returns true if the current array or object has another element.booleanReturns thebooleanvalue of the next token, consuming it.doubleReturns thedoublevalue of the next token, consuming it.intnextInt()Returns theintvalue of the next token, consuming it.longnextLong()Returns thelongvalue of the next token, consuming it.nextName()Returns the next token, aproperty name, and consumes it.voidnextNull()Consumes the next token from the JSON stream and asserts that it is a literal null.Returns thestringvalue of the next token, consuming it.peek()Returns the type of the next token without consuming it.voidvoidSkips the next value recursively.toString()Methods inherited from class JsonReader
isLenient, setLenient
-
Constructor Details
-
JsonTreeReader
-
-
Method Details
-
beginArray
Description copied from class:JsonReaderConsumes the next token from the JSON stream and asserts that it is the beginning of a new array.- Overrides:
beginArrayin classJsonReader- Throws:
IOException
-
endArray
Description copied from class:JsonReaderConsumes the next token from the JSON stream and asserts that it is the end of the current array.- Overrides:
endArrayin classJsonReader- Throws:
IOException
-
beginObject
Description copied from class:JsonReaderConsumes the next token from the JSON stream and asserts that it is the beginning of a new object.- Overrides:
beginObjectin classJsonReader- Throws:
IOException
-
endObject
Description copied from class:JsonReaderConsumes the next token from the JSON stream and asserts that it is the end of the current object.- Overrides:
endObjectin classJsonReader- Throws:
IOException
-
hasNext
Description copied from class:JsonReaderReturns true if the current array or object has another element.- Overrides:
hasNextin classJsonReader- Throws:
IOException
-
peek
Description copied from class:JsonReaderReturns the type of the next token without consuming it.- Overrides:
peekin classJsonReader- Throws:
IOException
-
nextName
Description copied from class:JsonReaderReturns the next token, aproperty name, and consumes it.- Overrides:
nextNamein classJsonReader- Throws:
IOException- if the next token in the stream is not a property name.
-
nextString
Description copied from class:JsonReaderReturns thestringvalue of the next token, consuming it. If the next token is a number, this method will return its string form.- Overrides:
nextStringin classJsonReader- Throws:
IOException
-
nextBoolean
Description copied from class:JsonReaderReturns thebooleanvalue of the next token, consuming it.- Overrides:
nextBooleanin classJsonReader- Throws:
IOException
-
nextNull
Description copied from class:JsonReaderConsumes the next token from the JSON stream and asserts that it is a literal null.- Overrides:
nextNullin classJsonReader- Throws:
IOException
-
nextDouble
Description copied from class:JsonReaderReturns thedoublevalue of the next token, consuming it. If the next token is a string, this method will attempt to parse it as a double usingDouble.parseDouble(String).- Overrides:
nextDoublein classJsonReader- Throws:
IOException
-
nextLong
Description copied from class:JsonReaderReturns thelongvalue 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 Javalong, this method throws.- Overrides:
nextLongin classJsonReader- Throws:
IOException
-
nextInt
Description copied from class:JsonReaderReturns theintvalue 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 Javaint, this method throws.- Overrides:
nextIntin classJsonReader- Throws:
IOException
-
close
Description copied from class:JsonReaderCloses this JSON reader and the underlyingReader.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classJsonReader- Throws:
IOException
-
skipValue
Description copied from class:JsonReaderSkips the next value recursively. If it is an object or array, all nested elements are skipped. This method is intended for use when the JSON token stream contains unrecognized or unhandled values.- Overrides:
skipValuein classJsonReader- Throws:
IOException
-
toString
- Overrides:
toStringin classJsonReader
-
promoteNameToValue
- Throws:
IOException
-
getPath
Description copied from class:JsonReaderReturns a JsonPath to the current location in the JSON value.- Overrides:
getPathin classJsonReader
-