public interface JSONReader extends java.lang.Iterable<JSONReader.EventType>, java.util.Iterator<JSONReader.EventType>
JSON: { "abc": "123" }
JSONFactory FACTORY = JSONFactory.instance();
JSONWriter r = FACTORY.makeReader(reader);
r.next(); // START_DOCUMENT
r.depth(); // depth = -1
r.next(); // START_OBJECT
r.next(); // START_VALUE
r.key(); // key = "abc"
r.next(); // STRING
r.value(); // value = "123"
r.next(); // END_VALUE
r.next(); // END_OBJECT
r.next(); // END_DOCUMENT
| Modifier and Type | Interface and Description |
|---|---|
static class |
JSONReader.EventType
The type of JSON events.
|
| Modifier and Type | Method and Description |
|---|---|
JSONDocument |
build()
Build an in-memory representation of the input JSON.
|
void |
close()
Close the underlying Reader when done reading.
|
int |
column()
The current column number in the JSON file.
|
int |
depth()
The reader's current depth in the JSON file.
|
java.lang.String |
key()
The name of the current JSON object.
|
int |
line()
The current line number in the JSON file.
|
JSONReader.EventType |
next(java.lang.String key,
int depth)
Skips until the specified object is found at the specified depth.
|
long |
offset()
The current byte offset in the underlying Reader.
|
java.lang.String[] |
path()
Returns the path from the root to the current position of the JSON file.
|
java.lang.String |
value()
The value of the current JSON object or array element.
|
java.lang.String key()
java.lang.String value()
JSONReader.EventType next(java.lang.String key, int depth)
key - the name of the object to find, may be nulldepth - stop at the first element at this depth, ignored if negativevoid close()
int line()
int column()
long offset()
int depth()
java.lang.String[] path()
JSONDocument build()