Interface IJSONService


public interface IJSONService
JSON服务
Author:
wangliang181230
  • Method Details

    • getName

      @NonNull String 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

      <T> T toBean(@NonNull String text, @NonNull Type targetType) throws JSONParseException
      转换为指定类型的对象
      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

      default Map<String,Object> toMap(String text)
      转换为指定类型的Map
      Parameters:
      text - 字符串
      Returns:
      目标类型的Map对象
      Throws:
      JSONParseException - JSON解析失败
      Since:
      0.7.4
    • toMap

      default <V> Map<String,V> toMap(String text, @NonNull Class<V> valueClazz)
      转换为 Key类型为String.class,Value类型为指定类型 的Map
      Type Parameters:
      V - 值类
      Parameters:
      text - 字符串
      valueClazz - 键值类型
      Returns:
      目标类型的Map对象
      Throws:
      JSONParseException - JSON解析失败
      Since:
      0.7.4
    • toMap2

      default <K> Map<K,Object> toMap2(String text, @NonNull Class<K> keyClazz)
      转换为 Key类型为指定类型,Value类型为Object.class 的Map
      Type Parameters:
      K - 键类
      Parameters:
      text - 字符串
      keyClazz - 键类型
      Returns:
      目标类型的Map对象
      Throws:
      JSONParseException - JSON解析失败
      Since:
      0.7.4
    • toMap3

      default <KV> Map<KV,KV> toMap3(String text, @NonNull Class<KV> keyValueClazz)
      转换为 Key类型和Value类型均为指定类型 的Map
      Type Parameters:
      KV - 键值类
      Parameters:
      text - 字符串
      keyValueClazz - 键值类型
      Returns:
      目标类型的Map对象
      Throws:
      JSONParseException - JSON解析失败
      Since:
      0.7.4
    • toJSONString

      @NonNull String toJSONString(@Nullable Object obj) throws JSONParseException
      转换为字符串
      Parameters:
      obj - 对象
      Returns:
      JSON字符串
      Throws:
      JSONParseException - 转换异常