public class JSONConverter extends Object implements Converter, Serializable
JSON,支持的对象:
| 限定符和类型 | 字段和说明 |
|---|---|
static JSONConverter |
INSTANCE
单例
|
| 构造器和说明 |
|---|
JSONConverter(JSONConfig config)
构造
|
| 限定符和类型 | 方法和说明 |
|---|---|
Object |
convert(Type targetType,
Object value) |
static JSONConverter |
of(JSONConfig config)
创建JSON转换器
|
Object |
toJSON(CharSequence str)
|
Object |
toJSON(Object obj)
实现Object对象转换为JSON对象,根据RFC8259规范,支持的对象:
String: 转换为相应的对象,"和'包围的字符串返回原字符串,""返回
null
Array、Iterable、Iterator:转换为JSONArray
Bean对象:转为JSONObject
Number、Boolean:返回原对象
null:返回null
|
public static final JSONConverter INSTANCE
public JSONConverter(JSONConfig config)
config - JSON配置public static JSONConverter of(JSONConfig config)
config - JSON配置public Object convert(Type targetType, Object value) throws ConvertException
convert 在接口中 ConverterConvertExceptionpublic Object toJSON(Object obj) throws JSONException
nullnullobj - 被转换的对象JSONException - 转换异常public Object toJSON(CharSequence str) throws JSONException
str - 被转换的字符串JSONException - 转换异常Copyright © 2024. All rights reserved.