程序包 cn.starrys.json

类 JsonUtils

java.lang.Object
cn.starrys.json.JsonUtils

public class JsonUtils extends Object
Json 工具。
同时实现了目前主流的Json解析库的使用。

creationTime: 2023/3/6 10:20 .

  • 构造器详细资料

    • JsonUtils

      public JsonUtils()
  • 方法详细资料

    • getValue

      public static <T> T getValue(String jsonStr, String keyPath, Class<T> type)
      获取Json串中指定节点的值。
      FastJson2 实现
      类型参数:
      T - 返回类型
      参数:
      jsonStr - Json 字符串
      keyPath - 节点路径
      type - 转换类型
      返回:
      指定类型的值
    • getValue2

      public static <T> T getValue2(String jsonStr, String keyPath, Class<T> type)
      获取Json串中指定节点的值。
      jackson 实现
      类型参数:
      T - 返回类型
      参数:
      jsonStr - Json 字符串
      keyPath - 节点路径
      type - 转换类型
      返回:
      指定类型的值
    • getValue3

      public static <T> T getValue3(String jsonStr, String keyPath, Class<T> type)
      获取Json串中指定节点的值。
      gson 实现
      类型参数:
      T - 返回类型
      参数:
      jsonStr - Json 字符串
      keyPath - 节点路径
      type - 转换类型
      返回:
      指定类型的值