public class JSONTokener extends Scanner
This class performed a lenient parse. For a strict parse, use
JSONStrictTokener.
| Modifier and Type | Class and Description |
|---|---|
static class |
JSONTokener.JSONToken
Tokens that can be identified with at most one character lookahead.
|
| Constructor and Description |
|---|
JSONTokener(java.io.InputStream inputStream)
Construct a JSONTokener from an InputStream, using the default
character set.
|
JSONTokener(java.io.InputStream inputStream,
java.nio.charset.Charset charset)
Construct a JSONTokener from an InputStream and supplied Charset.
|
JSONTokener(java.io.Reader reader)
Construct a JSONTokener from a Reader.
|
JSONTokener(java.lang.String s)
Construct a JSONTokener from a string.
|
| Modifier and Type | Method and Description |
|---|---|
char |
nextClean()
Get the next char in the string, skipping whitespace.
|
java.lang.String |
nextKey()
Get the next key.
|
java.lang.String |
nextString(char quote)
Return the characters up to the next close quote character.
|
JSONTokener.JSONToken |
nextTokenType()
Get the type of the next token in the stream, skipping whitespace.
|
java.lang.Object |
nextValue()
Get the next value.
|
protected java.lang.String |
pooledKey(java.lang.String key)
Add the given key to the key pool, if necessary, and return the
canonical key.
|
java.lang.String |
toString()
Make a printable string of this Scanner.
|
back, dehexchar, end, more, next, next, next, nextTo, nextTo, parsePosition, skipTo, syntaxError, syntaxError, syntaxErrorpublic JSONTokener(java.io.Reader reader)
reader - A reader.public JSONTokener(java.io.InputStream inputStream)
inputStream - an input stream from which to tokenize the JSON textpublic JSONTokener(java.io.InputStream inputStream,
java.nio.charset.Charset charset)
inputStream - an input stream from which to tokenize the JSON textcharset - the character set with which to interpret the input streampublic JSONTokener(java.lang.String s)
s - A source string.public char nextClean()
throws JSONException
JSONException - Thrown if there is an error reading the source string.public JSONTokener.JSONToken nextTokenType() throws JSONException
JSONExceptionJSONTokener.JSONTokenpublic java.lang.String nextString(char quote)
throws JSONException
quote - The quoting character, either
" (double quote) or
' (single quote).JSONException - Unterminated string.public java.lang.String nextKey()
throws JSONException
JSONException - If syntax error.protected java.lang.String pooledKey(java.lang.String key)
key - the key to be pooledpublic java.lang.Object nextValue()
throws JSONException
JSONException - If syntax error.