public class JsonParser
extends java.lang.Object
A non-blocking, event-based JSON parser.
The parser gets input data from a feeder that can be accessed through
getFeeder(). See JsonFeeder for more details.
| Constructor and Description |
|---|
JsonParser()
Constructs a JSON parser that uses the UTF-8 charset to decode input data
|
JsonParser(java.nio.charset.Charset charset)
Constructs a JSON parser
|
JsonParser(JsonFeeder feeder)
Constructs the JSON parser
|
| Modifier and Type | Method and Description |
|---|---|
double |
getCurrentDouble()
If the event returned by
nextEvent() was
JsonEvent.VALUE_DOUBLE this method will return the parsed double |
int |
getCurrentInt()
If the event returned by
nextEvent() was
JsonEvent.VALUE_INT this method will return the parsed integer |
java.lang.String |
getCurrentString()
If the event returned by
nextEvent() was
JsonEvent.VALUE_STRING this method will return the parsed string |
JsonFeeder |
getFeeder()
Get the feeder that can be used to provide more input to the parser
|
int |
getMaxDepth() |
int |
nextEvent()
Call this method to proceed parsing the JSON text and to get the next
event.
|
void |
setMaxDepth(int depth)
Set the maximum number of modes on the stack (basically the maximum number
of nested objects/arrays in the JSON text to parse)
|
public JsonParser()
public JsonParser(java.nio.charset.Charset charset)
charset - the charset that should be used to decode the
parser's input datapublic JsonParser(JsonFeeder feeder)
feeder - the feeder that will provide the parser with input datapublic void setMaxDepth(int depth)
depth - the maximum number of modespublic int getMaxDepth()
public int nextEvent()
JsonEvent.NEED_MORE_INPUT if it needs
more input data from the parser's feeder.JsonEvent.NEED_MORE_INPUT if more
input is neededpublic JsonFeeder getFeeder()
public java.lang.String getCurrentString()
nextEvent() was
JsonEvent.VALUE_STRING this method will return the parsed stringpublic int getCurrentInt()
nextEvent() was
JsonEvent.VALUE_INT this method will return the parsed integerpublic double getCurrentDouble()
nextEvent() was
JsonEvent.VALUE_DOUBLE this method will return the parsed double