当前位置: 代码迷 >> 综合 >> gson 泛型对象 转换
  详细解决方案

gson 泛型对象 转换

热度:1   发布时间:2024-01-28 12:19:00.0

JsonUtil.fromJson(body, new TypeToken<BaseReqVo<EnterNotifyReqVo>>(){}.getType());

用 TypeToken 构造一个 BaseReqVo<EnterNotifyReqVo> 的 type

    public static <T> T fromJson(String str, Type type) {
return getGsonInstance().fromJson(str, type);
}