getPrevious
protected char getPrevious()
Get the last character read from the input or '\0' if nothing has been read yet.
Returns:
the last character read from the input.
public String nextString(char quote)
throws JSONException
返回当前位置到指定引号前的所有字符,反斜杠的转义符也会被处理。
标准的JSON是不允许使用单引号包含字符串的,但是此实现允许。
Parameters:
quote
- 字符引号, 包括
"
(双引号) 或
'
(单引号)。
Returns:
截止到引号前的字符串
Throws:
JSONException
- 出现无结束的字符串时抛出此异常
public String nextTo(char delimiter)
throws JSONException
Get the text up but not including the specified character or the end of line, whichever comes first.
获得从当前位置直到分隔符(不包括分隔符)或行尾的的所有字符。
Parameters:
delimiter
- 分隔符
Returns:
Throws:
JSONException
public String nextTo(String delimiters)
throws JSONException
Get the text up but not including one of the specified delimiter characters or the end of line, whichever comes first.
Parameters:
delimiters
- A set of delimiter characters.
Returns:
A string, trimmed.
Throws:
JSONException
public Object nextValue()
throws JSONException
获得下一个值,值类型可以是Boolean, Double, Integer, JSONArray, JSONObject, Long, or String, or the JSONObject.NULL
Returns:
Boolean, Double, Integer, JSONArray, JSONObject, Long, or String, or the JSONObject.NULL
Throws:
JSONException
- 语法错误
public char skipTo(char to)
throws JSONException
Skip characters until the next character is the requested character. If the requested character is not found, no characters are skipped. 在遇到指定字符前,跳过其它字符。如果字符未找到,则不跳过任何字符。
Parameters:
to
- 需要定位的字符
Returns:
定位的字符,如果字符未找到返回0
Throws:
JSONException
syntaxError
public JSONException syntaxError(String message)
Make a JSONException to signal a syntax error.
构建 JSONException 用于表示语法错误
Parameters:
message
- 错误消息
Returns:
A JSONException object, suitable for throwing