当前位置: 代码迷 >> 综合 >> FASTJSON 增加对泛型的支持
  详细解决方案

FASTJSON 增加对泛型的支持

热度:42   发布时间:2023-12-21 15:51:26.0
FASTJSON 默认没有开启对泛型的支持。通过SerializerFeature.WriteClassName增加


Map<String, Date> map = new HashMap<String, Date>();
map.put("now", new Date());

String str = JSON.toJSONString(map,SerializerFeature.WriteClassName);
System.out.println(str);
Map<String, Date> result = JSON.parseObject(str, map.getClass());
System.out.println(result.get("now").getClass());