| 程序包 | 说明 |
|---|---|
| com.xiaoleilu.hutool.http | |
| com.xiaoleilu.hutool.io | |
| com.xiaoleilu.hutool.io.file | |
| com.xiaoleilu.hutool.json |
| 限定符和类型 | 方法和说明 |
|---|---|
HttpRequest |
HttpRequest.body(JSON json)
设置JSON内容主体
设置默认的Content-Type为 application/json 需在此方法调用前使用charset方法设置编码,否则使用默认编码UTF-8 |
| 限定符和类型 | 方法和说明 |
|---|---|
static JSON |
FileUtil.readJSON(File file,
Charset charset)
读取JSON
|
static JSON |
FileUtil.readJSON(File file,
String charsetName)
读取JSON
|
| 限定符和类型 | 方法和说明 |
|---|---|
JSON |
FileReader.readJSON()
读取JSON
|
| 限定符和类型 | 类和说明 |
|---|---|
class |
JSONArray
JSON数组
|
class |
JSONObject
JSON对象
例: myString = new JSONObject().put("JSON", "Hello, World! |
| 限定符和类型 | 方法和说明 |
|---|---|
static JSON |
JSONUtil.parse(Object obj)
转换对象为JSON
支持的对象: String: 转换为相应的对象 Array Collection:转换为JSONArray Bean对象:转为JSONObject |
| 限定符和类型 | 方法和说明 |
|---|---|
static String |
JSONUtil.toJsonPrettyStr(JSON json)
转为JSON字符串
|
static String |
JSONUtil.toJsonStr(JSON json)
转为JSON字符串
|
static String |
JSONUtil.toJsonStr(JSON json,
int indentFactor)
转为JSON字符串
|
static String |
JSONUtil.toXmlStr(JSON json)
转换为XML字符串
|
Copyright © 2017. All rights reserved.