| Constructor and Description |
|---|
JSONConverter() |
| Modifier and Type | Method and Description |
|---|---|
JSON |
convert(Object value,
JSON defaultValue)
转换为指定类型
如果类型无法确定,将读取默认值的类型做为目标类型 |
protected static <T> T |
jsonConvert(Type targetType,
Object value,
JSONConfig jsonConfig)
|
protected static <T> T |
jsonToBean(Type targetType,
Object value,
boolean ignoreError)
JSON递归转换
首先尝试JDK类型转换,如果失败尝试JSON转Bean |
protected static Object |
toArray(JSONArray jsonArray,
Class<?> arrayClass)
JSONArray转数组
|
protected static <T> List<T> |
toList(JSONArray jsonArray,
Class<T> elementType)
将JSONArray转换为指定类型的对量列表
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitconvertWithCheckprotected static Object toArray(JSONArray jsonArray, Class<?> arrayClass)
jsonArray - JSONArrayarrayClass - 数组元素类型protected static <T> List<T> toList(JSONArray jsonArray, Class<T> elementType)
T - 元素类型jsonArray - JSONArrayelementType - 对象元素类型protected static <T> T jsonConvert(Type targetType, Object value, JSONConfig jsonConfig) throws ConvertException
T - 转换后的对象类型targetType - 目标类型value - 值jsonConfig - JSON配置ConvertException - 转换失败protected static <T> T jsonToBean(Type targetType, Object value, boolean ignoreError) throws ConvertException
T - 转换后的对象类型targetType - 目标类型value - 值,JSON格式ignoreError - 是否忽略转换错误ConvertException - 转换失败public JSON convert(Object value, JSON defaultValue) throws IllegalArgumentException
Converterconvert in interface Converter<JSON>value - 原始值defaultValue - 默认值IllegalArgumentException - 无法确定目标类型,且默认值为null,无法确定类型Copyright © 2025. All rights reserved.