| java.lang.Object | |
| ↳ | com.google.gson.JsonStreamParser |
A streaming parser that allows reading of multiple JsonElements from the specified reader
asynchronously.
This class is conditionally thread-safe (see Item 70, Effective Java second edition). To properly use this class across multiple threads, you will need to add some external synchronization. For example:
JsonStreamParser parser = new JsonStreamParser("['first'] {'second':10} 'third'");
JsonElement element;
synchronized (parser) { // synchronize on an object shared by threads
if (parser.hasNext()) {
element = parser.next();
}
}
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| JsonStreamParser(String json) | |||||||||||
| JsonStreamParser(Reader reader) | |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| boolean |
hasNext()
Returns true if a
JsonElement is available on the input for consumption | ||||||||||
| JsonElement |
next()
Returns the next available
JsonElement on the reader. | ||||||||||
| void |
remove()
This optional
Iterator method is not relevant for stream parsing and hence is not
implemented. | ||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
java.util.Iterator
| |||||||||||
| json | The string containing JSON elements concatenated to each other. |
|---|
| reader | The data stream containing JSON elements concatenated to each other. |
|---|
Returns true if a JsonElement is available on the input for consumption
JsonElement is available on the input, false otherwiseReturns the next available JsonElement on the reader. Null if none available.
JsonElement on the reader. Null if none available.| JsonParseException | if the incoming stream is malformed JSON. |
|---|
This optional Iterator method is not relevant for stream parsing and hence is not
implemented.