public class JSONTokener extends Object
Constructor and Description |
---|
JSONTokener(CharSequence s,
JSONConfig config)
从字符串中构建
|
JSONTokener(InputStream inputStream,
JSONConfig config)
从InputStream中构建,使用UTF-8编码
|
JSONTokener(Reader reader,
JSONConfig config)
从Reader中构建
|
Modifier and Type | Method and Description |
---|---|
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 |
nextStringValue()
获取下一个String格式的值,用户获取key
|
String |
nextTo(char delimiter)
Get the text up but not including the specified character or the end of line, whichever comes first.
|
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, Double, Integer, JSONArray, JSONObject, Long, or String, or the JSONObject.NULL
|
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.
|
JSONArray |
toJSONArray()
转为
JSONArray |
String |
toString()
Make a printable string of this JSONTokener.
|
public JSONTokener(Reader reader, JSONConfig config)
reader
- Readerconfig
- JSON配置public JSONTokener(InputStream inputStream, JSONConfig config) throws JSONException
inputStream
- InputStreamconfig
- JSON配置JSONException
public JSONTokener(CharSequence s, JSONConfig config)
s
- JSON字符串config
- JSON配置public void back() throws JSONException
JSONException
public boolean end()
public boolean more() throws JSONException
JSONException
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
public String nextTo(String delimiters) throws JSONException
delimiters
- A set of delimiter characters.JSONException
public String nextStringValue()
public Object nextValue() throws JSONException
JSONException
- 语法错误public char skipTo(char to) throws JSONException
to
- 需要定位的字符JSONException
public JSONException syntaxError(String message)
message
- 错误消息Copyright © 2024. All rights reserved.