| 程序包 | 说明 |
|---|---|
| com.xiaoleilu.hutool.json |
| 限定符和类型 | 方法和说明 |
|---|---|
JSONException |
JSONTokener.syntaxError(String message)
Make a JSONException to signal a syntax error.
|
| 限定符和类型 | 方法和说明 |
|---|---|
JSONObject |
JSONObject.accumulate(String key,
Object value)
积累值。
|
JSONObject |
JSONObject.append(String key,
Object value)
追加值,如果key无对应值,就添加一个JSONArray,其元素只有value,如果值已经是一个JSONArray,则添加到值JSONArray中。
|
void |
JSONTokener.back()
将标记回退到第一个字符,重新开始解析新的JSON
|
JSONObject |
JSONObject.increment(String key)
对值加一,如果值不存在,赋值1,如果为数字类型,做加一操作
|
String |
JSONArray.join(String separator)
Make a string from the contents of this JSONArray.
|
boolean |
JSONTokener.more()
源字符串是否有更多的字符
|
char |
JSONTokener.next()
获得源字符串中的下一个字符
|
char |
JSONTokener.next(char c)
读取下一个字符,并比对是否和指定字符匹配
|
String |
JSONTokener.next(int n)
获得接下来的n个字符
|
String |
XMLTokener.nextCDATA()
Get the text in the CDATA block.
|
char |
JSONTokener.nextClean()
获得下一个字符,跳过空白符
|
Object |
XMLTokener.nextContent()
Get the next XML outer token, trimming whitespace.
|
Object |
XMLTokener.nextEntity(char ampersand)
Return the next entity.
|
Object |
XMLTokener.nextMeta()
Returns the next XML meta token.
|
String |
JSONTokener.nextString(char quote)
返回当前位置到指定引号前的所有字符,反斜杠的转义符也会被处理。
|
String |
JSONTokener.nextTo(char delimiter)
Get the text up but not including the specified character or the end of line, whichever comes first.
|
String |
JSONTokener.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 |
XMLTokener.nextToken()
Get the next XML Token.
|
Object |
JSONTokener.nextValue()
获得下一个值,值类型可以是Boolean, Double, Integer, JSONArray, JSONObject, Long, or String, or the JSONObject.NULL
|
static void |
XML.noSpace(String string)
Throw an exception if the string contains whitespace.
|
protected static String |
JSONUtil.numberToString(Number number)
Produce a string from a Number.
|
JSONArray |
JSONArray.put(int index,
Object value)
加入或者替换JSONArray中指定Index的值,如果index大于JSONArray的长度,将在指定index设置值,之前的位置填充JSONNull.Null
|
JSONObject |
JSONObject.put(String key,
Object value)
PUT 键值对到JSONObject中,如果值为
null,将此键移除 |
JSONObject |
JSONObject.putOnce(String key,
Object value)
Put a key/value pair in the JSONObject, but only if the key and the value are both non-null,
and only if there is not already a member with that name. |
JSONObject |
JSONObject.putOpt(String key,
Object value)
在键和值都为非空的情况下put到JSONObject中
|
boolean |
XMLTokener.skipPast(String to)
Skip characters until past the requested string.
|
char |
JSONTokener.skipTo(char to)
Skip characters until the next character is the requested character.
|
protected static void |
JSONUtil.testValidity(Object obj)
如果对象是Number 且是 NaN or infinite,将抛出异常
|
JSONArray |
JSONObject.toJSONArray(Collection<String> names)
将指定KEY列表的值组成新的JSONArray
|
JSONObject |
JSONArray.toJSONObject(JSONArray names)
Produce a JSONObject by combining a JSONArray of names with the values of this JSONArray.
|
static JSONObject |
XML.toJSONObject(String string)
Convert a well-formed (but not necessarily valid) XML string into a JSONObject.
|
static JSONObject |
XML.toJSONObject(String string,
boolean keepStrings)
Convert a well-formed (but not necessarily valid) XML string into a JSONObject.
|
String |
JSONObject.toJSONString(int indentFactor)
Make a prettyprinted JSON text of this JSONObject.
|
String |
JSONArray.toJSONString(int indentFactor)
Make a prettyprinted JSON text of this JSONArray.
|
String |
JSON.toJSONString(int indentFactor)
转换为JSON字符串
|
static String |
XML.toString(Object object)
Convert a JSONObject into a well-formed, element-normal XML string.
|
static String |
XML.toString(Object object,
String tagName)
Convert a JSONObject into a well-formed, element-normal XML string.
|
protected static String |
JSONUtil.valueToString(Object value)
Make a JSON text of an Object value.
|
Writer |
JSONObject.write(Writer writer) |
Writer |
JSONArray.write(Writer writer) |
Writer |
JSON.write(Writer writer)
将JSON内容写入Writer,无缩进
Warning: This method assumes that the data structure is acyclical. |
Writer |
JSONObject.write(Writer writer,
int indentFactor,
int indent) |
Writer |
JSONArray.write(Writer writer,
int indentFactor,
int indent) |
Writer |
JSON.write(Writer writer,
int indentFactor,
int indent)
将JSON内容写入Writer
Warning: This method assumes that the data structure is acyclical. |
protected static Writer |
JSONUtil.writeValue(Writer writer,
Object value,
int indentFactor,
int indent)
写入值到Writer
|
| 构造器和说明 |
|---|
JSONArray(JSONTokener x)
Construct a JSONArray from a JSONTokener.
|
JSONArray(Object arrayOrCollection)
Construct a JSONArray from an array or Collection
|
JSONArray(String source)
Construct a JSONArray from a source JSON text.
|
JSONObject(JSONTokener x)
Construct a JSONObject from a JSONTokener.
|
JSONObject(String source)
从JSON字符串解析为JSON对象
|
JSONTokener(InputStream inputStream)
从InputStream中构建
|
Copyright © 2017. All rights reserved.