|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface JsonHandler
A SAX-inspired streaming interface for JSON. This interface is biased towards streaming writing whereas SAX is biased towards streaming parsing.
Method Summary | |
---|---|
void |
bool(boolean bool)
Reports a boolean. |
void |
characters(char[] ch,
int start,
int length)
Adds characters to the current string started with startString() . |
void |
endArray()
Reports the end of an array. |
void |
endDocument()
Reports the end of the JSON file. |
void |
endObject()
Reports the end of an object. |
void |
endString()
Reports the end of a string. |
void |
key(String key)
Starts a key-value pair inside an object. |
void |
number(double number)
Reports a number. |
void |
number(float number)
Reports a number. |
void |
number(int number)
Reports a number. |
void |
number(long number)
Reports a number. |
void |
startArray()
Reports the start of an array. |
void |
startDocument(String callback)
Reports the start of the JSON file. |
void |
startObject()
Reports the start of an object. |
void |
startString()
Reports the start of a string. |
void |
string(String string)
Reports a JSON null on null and
a string otherwise. |
Method Detail |
---|
void startDocument(String callback) throws SAXException
callback
is
null
, the file is a pure JSON file. With a non-null
callback
, a JSON value is wrapped in a function call named
callback.
Note that the JSON null value is represented as
string(null)
.
callback
- JavaScript callback function name or null
for
pure JSON.
SAXException
- if bad things happenvoid endDocument() throws SAXException
finally
.
SAXException
- if bad things happenvoid startArray() throws SAXException
SAXException
- if bad things happenvoid endArray() throws SAXException
SAXException
- if bad things happenvoid startObject() throws SAXException
SAXException
- if bad things happenvoid key(String key) throws SAXException
key
gives the key and the next
reported value is taken to be the value associated with
the key. (Hence, there is no need for a corresponding
end
callback.)
key
- the key for the key-value pair (must not be null
)
SAXException
- if bad things happenvoid endObject() throws SAXException
SAXException
- if bad things happenvoid startString() throws SAXException
SAXException
- if bad things happenvoid characters(char[] ch, int start, int length) throws SAXException
startString()
.
ch
- a buffer of UTF-16 code unitsstart
- the first code unit to readlength
- the number of code units to read
SAXException
- if bad things happenvoid endString() throws SAXException
SAXException
- if bad things happenvoid string(String string) throws SAXException
null
and
a string otherwise.
When the argument is not null
, this method is
shorthand for
startString(); characters(string.toCharArray(), 0, string.length()); endString();
string
- a string or null
SAXException
- if bad things happenvoid number(int number) throws SAXException
number
- the number
SAXException
- if bad things happenvoid number(long number) throws SAXException
number
- the number
SAXException
- if bad things happenvoid number(float number) throws SAXException
number
- the number
SAXException
- if bad things happenvoid number(double number) throws SAXException
number
- the number
SAXException
- if bad things happenvoid bool(boolean bool) throws SAXException
bool
- the boolean
SAXException
- if bad things happen
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |