public interface JSONReader extends Iterable<JSONReader.EventType>, 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.
|
String |
key()
The name of the current JSON object.
|
int |
line()
The current line number in the JSON file.
|
JSONReader.EventType |
next(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.
|
String[] |
path()
Returns the path from the root to the current position of the JSON file.
|
String |
value()
The value of the current JSON object or array element.
|
forEach, iterator, spliterator
forEachRemaining, hasNext, next, remove
String key()
String value()
JSONReader.EventType next(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()
String[] path()
JSONDocument build()
Copyright © 2020. All rights reserved.