|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.google.gson.JsonStreamParser
public final class 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();
}
}
| Constructor Summary | |
|---|---|
JsonStreamParser(Reader reader)
|
|
JsonStreamParser(String json)
|
|
| Method Summary | |
|---|---|
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public JsonStreamParser(String json)
json - The string containing JSON elements concatenated to each other.public JsonStreamParser(Reader reader)
reader - The data stream containing JSON elements concatenated to each other.| Method Detail |
|---|
public JsonElement next()
throws JsonParseException
JsonElement on the reader. Null if none available.
next in interface Iterator<JsonElement>JsonElement on the reader. Null if none available.
JsonParseException - if the incoming stream is malformed JSON.public boolean hasNext()
JsonElement is available on the input for consumption
hasNext in interface Iterator<JsonElement>JsonElement is available on the input, false otherwisepublic void remove()
Iterator method is not relevant for stream parsing and hence is not
implemented.
remove in interface Iterator<JsonElement>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||