类 JsonUtils


  • public class JsonUtils
    extends Object
    从以下版本开始:
    2024-05-20
    作者:
    SHOUSHEN.LUAN
    • 构造器详细资料

      • JsonUtils

        public JsonUtils()
    • 方法详细资料

      • serialize

        public static String serialize​(Object object)
        将参数对象输出为 JSON 字符串
      • deserialize

        public static <T> T deserialize​(String json,
                                        Class<T> clazz)
                                 throws IOException
        读取 JSON 字符串返回对应的 Java 对象
        抛出:
        IOException
      • fromJsonArray

        public static <T> List<T> fromJsonArray​(String json,
                                                Class<T> clazz)
                                         throws IOException
        读取 JSON 字符串返回对应的 Java 对象列表
        参数:
        json - JSON 数组字符串
        clazz - 数组中单个元素的类型
        抛出:
        IOException
      • writeValue

        public static void writeValue​(Writer writer,
                                      Object object)
                               throws IOException
        将参数对象输出为 JSON 字符串并写入到 writer
        抛出:
        IOException
      • deserialize

        public static <T> T deserialize​(String json,
                                        Type type)