public class JSONParser extends Object implements JSONParseCallback
Constructor and Description |
---|
JSONParser() |
Modifier and Type | Method and Description |
---|---|
void |
endArray(String arrayName)
Indicates that the parser ran into an ending bracket event ]
|
void |
endBlock(String blockName)
Indicates that the parser ran into an ending bracket event }
|
boolean |
isAlive()
This method indicates to the Parser if this Callback is still alive
|
static boolean |
isUseLongs()
Indicates that the parser will generate long objects and not just doubles for numeric values
|
void |
keyValue(String key,
String value)
This method is called when a string key/value pair is detected within the json
it is essentially redundant when following string/numeric token.
|
void |
longToken(long tok)
Submits a numeric token from the JSON data
|
void |
numericToken(double tok)
Submits a numeric token from the JSON data
|
Hashtable<String,Object> |
parse(Reader i)
Deprecated.
use the new parseJSON instead
|
static void |
parse(Reader i,
JSONParseCallback callback)
Static method! Parses the given input stream and fires the data into the given callback.
|
Map<String,Object> |
parseJSON(Reader i)
Parses the given input stream into this object and returns the parse tree
|
static void |
setUseLongs(boolean aUseLongsDefault)
Indicates that the parser will generate long objects and not just doubles for numeric values
|
void |
startArray(String arrayName)
Indicates that the parser ran into an opening bracket event [
|
void |
startBlock(String blockName)
Indicates that the parser ran into an opening bracket event {
|
void |
stringToken(String tok)
Submits a token from the JSON data as a java string, this token is always a string value
|
public static boolean isUseLongs()
public static void setUseLongs(boolean aUseLongsDefault)
aUseLongsDefault
- the useLongsDefault to setpublic static void parse(Reader i, JSONParseCallback callback) throws IOException
i
- the readercallback
- a generic callback to receive the parse eventsIOException
- if thrown by the streampublic Map<String,Object> parseJSON(Reader i) throws IOException
i
- the readerIOException
- if thrown by the streampublic Hashtable<String,Object> parse(Reader i) throws IOException
i
- the readerIOException
- if thrown by the streampublic void startBlock(String blockName)
JSONParseCallback
startBlock
in interface JSONParseCallback
public void endBlock(String blockName)
JSONParseCallback
endBlock
in interface JSONParseCallback
public void startArray(String arrayName)
JSONParseCallback
startArray
in interface JSONParseCallback
public void endArray(String arrayName)
JSONParseCallback
endArray
in interface JSONParseCallback
public void stringToken(String tok)
JSONParseCallback
stringToken
in interface JSONParseCallback
public void numericToken(double tok)
JSONParseCallback
numericToken
in interface JSONParseCallback
public void longToken(long tok)
JSONParseCallback
longToken
in interface JSONParseCallback
public void keyValue(String key, String value)
JSONParseCallback
keyValue
in interface JSONParseCallback
key
- the keyvalue
- a string valuepublic boolean isAlive()
JSONParseCallback
isAlive
in interface JSONParseCallback