Package icu.easyj.core.json
Interface IJSONService
public interface IJSONService
JSON服务
- Author:
- wangliang181230
-
Method Summary
Modifier and TypeMethodDescriptiongetName()获取服务名<T> T转换为指定类型的对象default <T> T转换为指定泛型类型的对象<T> T转换为指定类型的对象toJSONString(Object obj) 转换为字符串<T> List<T>转换为指定类型的List转换为指定类型的Mapdefault <K,V> Map<K, V> 转换为指定类型的Map转换为 Key类型为String.class,Value类型为指定类型 的Map转换为 Key类型为指定类型,Value类型为Object.class 的Mapdefault <KV> Map<KV,KV> 转换为 Key类型和Value类型均为指定类型 的Map
-
Method Details
-
getName
获取服务名- Returns:
- 服务名
-
toBean
@NonNull <T> T toBean(@NonNull String text, @NonNull Class<T> targetClazz) throws JSONParseException 转换为指定类型的对象- Type Parameters:
T- 目标类- Parameters:
text- 字符串targetClazz- 目标类型- Returns:
- 目标类型的对象
- Throws:
JSONParseException- 转换异常
-
toBean
转换为指定类型的对象- Type Parameters:
T- 目标类- Parameters:
text- 字符串targetType- 目标类型- Returns:
- 目标类型的对象
- Throws:
JSONParseException- 转换异常
-
toBean
default <T> T toBean(@NonNull String text, @NonNull Class<T> rawType, Type... actualTypeArguments) throws JSONParseException 转换为指定泛型类型的对象- Type Parameters:
T- 目标泛型类- Parameters:
text- 字符串rawType- 目标泛型类型actualTypeArguments- 泛型实际类型数组- Returns:
- 目标泛型类型的对象
- Throws:
JSONParseException- 转换异常
-
toList
@NonNull <T> List<T> toList(@NonNull String text, @NonNull Class<T> targetClazz) throws JSONParseException 转换为指定类型的List- Type Parameters:
T- 目标类- Parameters:
text- 字符串targetClazz- 目标类型- Returns:
- 目标类型的列表对象
- Throws:
JSONParseException- 转换异常
-
toMap
default <K,V> Map<K,V> toMap(String text, @NonNull Class<K> keyClazz, @NonNull Class<V> valueClazz) 转换为指定类型的Map- Type Parameters:
K- 键类V- 值类- Parameters:
text- 字符串keyClazz- 键类型valueClazz- 值类型- Returns:
- 目标类型的Map对象
- Throws:
JSONParseException- JSON解析失败- Since:
- 0.7.4
-
toMap
转换为指定类型的Map- Parameters:
text- 字符串- Returns:
- 目标类型的Map对象
- Throws:
JSONParseException- JSON解析失败- Since:
- 0.7.4
-
toMap
转换为 Key类型为String.class,Value类型为指定类型 的Map- Type Parameters:
V- 值类- Parameters:
text- 字符串valueClazz- 键值类型- Returns:
- 目标类型的Map对象
- Throws:
JSONParseException- JSON解析失败- Since:
- 0.7.4
-
toMap2
转换为 Key类型为指定类型,Value类型为Object.class 的Map- Type Parameters:
K- 键类- Parameters:
text- 字符串keyClazz- 键类型- Returns:
- 目标类型的Map对象
- Throws:
JSONParseException- JSON解析失败- Since:
- 0.7.4
-
toMap3
转换为 Key类型和Value类型均为指定类型 的Map- Type Parameters:
KV- 键值类- Parameters:
text- 字符串keyValueClazz- 键值类型- Returns:
- 目标类型的Map对象
- Throws:
JSONParseException- JSON解析失败- Since:
- 0.7.4
-
toJSONString
转换为字符串- Parameters:
obj- 对象- Returns:
- JSON字符串
- Throws:
JSONParseException- 转换异常
-