public final class JSONParser extends Object
JSONParseListener
Modifier and Type | Method and Description |
---|---|
static void |
parse(JSONParseListener l,
Reader reader)
Parses the specified Reader's contents with the specified ParseListener.
|
static void |
parse(JSONParseListener l,
Reader reader,
int skipChars)
This starts by firing l's
started()
method. |
static void |
parse(JSONParseListener l,
String s)
Parses a string to a JSONParseListener
|
static void |
parse(JSONParseListener l,
String s,
int skipChars)
Parses the specified String's contents with the specified ParseListener
after skipping the specified number of characters.
|
public static void parse(JSONParseListener l, String s) throws NullPointerException, ParseException
l
- the ParseListener that recieves events from this parsers
- a string to create a StringReader
aroundNullPointerException
- if either l or reader is nullParseException
- if the parsing failspublic static void parse(JSONParseListener l, String s, int skipChars) throws NullPointerException, ParseException
l
- the ParseListener that recieves events from this parsers
- a string to create a StringReader
aroundskipChars
- the number of characters to skip in the reader before starting. This assumes any value after zero is after the initial '{' or '['.NullPointerException
- if either l or reader is nullParseException
- if the parsing failspublic static void parse(JSONParseListener l, Reader reader) throws NullPointerException, ParseException, IOException
l
- the ParseListener that recieves events from this parserreader
- the reader that this will read chars from. It is assumed to be at the beginning of the streamNullPointerException
- if either l or reader is nullParseException
- if the parsing failsIOException
- if the reader could not be read frompublic static void parse(JSONParseListener l, Reader reader, int skipChars) throws NullPointerException, ParseException, IOException
started()
method. This will then take reader, skip skipChars, then
silently read until it reaches a comma or bracket. Begining there it will fire an
openingBracket(int, char)
if appropriate and an
elemStarted(int, char)
on l. It will continue reading characters
and firing appropriate events until reader runs out of characters
or l's abort()
method returns true.
Then ended()
is called and the method returns.
This neither throws exceptions nor performs any logic at all. Logic includes determining that a list or element is empty or leaving out whitespace. Listeners can handle such cases individually.
l
- the ParseListener that recieves events from this parserreader
- the reader that this will read chars from. It is assumed to be at the beginning of the streamskipChars
- the number of characters to skip in the reader before starting. This assumes any value after zero is after the initial '{' or '['.NullPointerException
- if either l or reader is nullParseException
- if the parsing failsIOException
- if the reader could not be read from