fastjson对象转为json字符串日期格式变为时间戳问题

将map集合转为json对象时遇到一个问题,map中的value为日期格式如"2019-03-01",在使用 JSONObject.toJSON(map).toString() 转换后的value变成了时间戳,显示出来很不友好。

fastjson的API中有个方法可以将对象中的时间格式不转化为时间戳的方法:

JSON.toJSONStringWithDateFormat(Object,dateformat,SerializerFeature.WriteDateUseDateFormat)

例如

JSON.toJSONStringWithDateFormat(map, "yyyy-MM-dd HH:mm:ss", SerializerFeature.WriteDateUseDateFormat);

 

posted @ 2020-07-03 13:44  如何下笔呢  阅读(6147)  评论(0编辑  收藏  举报
levels of contents