public class JSONTokener extends ReaderWrapper
raw| 构造器和说明 |
|---|
JSONTokener(CharSequence s,
JSONConfig config)
从字符串中构建
|
JSONTokener(InputStream inputStream,
JSONConfig config)
从InputStream中构建,使用UTF-8编码
|
JSONTokener(Reader reader,
JSONConfig config)
从Reader中构建
|
| 限定符和类型 | 方法和说明 |
|---|---|
void |
back()
将标记回退到第一个字符,重新开始解析新的JSON
|
boolean |
end() |
protected char |
getPrevious()
Get the last character read from the input or '\0' if nothing has been read yet.
|
boolean |
more()
源字符串是否有更多的字符
|
char |
next()
获得源字符串中的下一个字符
|
char |
next(char c)
读取下一个字符,并比对是否和指定字符匹配
|
String |
next(int n)
获得接下来的n个字符
|
char |
nextClean()
获得下一个字符,跳过空白符
|
String |
nextString(char quote)
返回当前位置到指定引号前的所有字符,反斜杠的转义符也会被处理。
|
String |
nextTo(char delimiter)
获得从当前位置直到分隔符(不包括分隔符)或行尾的的所有字符。
|
String |
nextTo(String delimiters)
Get the text up but not including one of the specified delimiter characters or the end of line, whichever comes first.
|
Object |
nextValue(boolean getOnlyStringValue)
获得下一个值,值类型可以是Boolean, Double, Integer, JSONArray, JSONObject, Long, or String
|
char |
skipTo(char to)
Skip characters until the next character is the requested character.
|
JSONException |
syntaxError(String message)
Make a JSONException to signal a syntax error.
|
String |
toString()
Make a printable string of this JSONTokener.
|
public JSONTokener(InputStream inputStream, JSONConfig config) throws JSONException
inputStream - InputStreamconfig - JSON配置JSONException - JSON异常,包装IO异常public JSONTokener(CharSequence s, JSONConfig config)
s - JSON字符串config - JSON配置public JSONTokener(Reader reader, JSONConfig config)
reader - Readerconfig - JSON配置public void back()
throws JSONException
JSONException - JSON异常,包装IO异常public boolean end()
public boolean more()
throws JSONException
JSONException - JSON异常,包装IO异常public char next()
throws JSONException
JSONException - JSON异常,包装IO异常protected char getPrevious()
public char next(char c)
throws JSONException
c - 被匹配的字符JSONException - 如果不匹配抛出此异常public String next(int n) throws JSONException
n - 字符数JSONException - 如果源中余下的字符数不足以提供所需的字符数,抛出此异常public char nextClean()
throws JSONException
JSONException - 获得下一个字符时抛出的异常public String nextString(char quote) throws JSONException
quote - 字符引号, 包括 "(双引号) 或 '(单引号)。JSONException - 出现无结束的字符串时抛出此异常public String nextTo(char delimiter) throws JSONException
delimiter - 分隔符JSONException - JSON异常,包装IO异常public String nextTo(String delimiters) throws JSONException
delimiters - A set of delimiter characters.JSONException - JSON异常,包装IO异常public Object nextValue(boolean getOnlyStringValue) throws JSONException
JSONException - 语法错误public char skipTo(char to)
throws JSONException
to - 需要定位的字符JSONException - IO异常public JSONException syntaxError(String message)
message - 错误消息Copyright © 2023. All rights reserved.