public final class JsonStreamParser extends java.lang.Object implements java.util.Iterator<JsonElement>
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 and Description |
|---|
JsonStreamParser(java.io.Reader reader) |
JsonStreamParser(java.lang.String json) |
| Modifier and Type | Method and Description |
|---|---|
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. |
public JsonStreamParser(java.lang.String json)
json - The string containing JSON elements concatenated to each other.public JsonStreamParser(java.io.Reader reader)
reader - The data stream containing JSON elements concatenated to each other.public JsonElement next() throws JsonParseException
JsonElement on the reader. Null if none available.next in interface java.util.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 consumptionhasNext in interface java.util.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 java.util.Iterator<JsonElement>Copyright © 2018. All Rights Reserved.