- why...
为什么会有这个问题; 由于近期用到需要将数据序列化... 最终选择了fastJSON(版本为1.0.0.0)来实现。 但是发现了一个问题,表中有一个dateTime类型的字段, 本来数据库中存入的是: Time: "2016-07-22 18:01:35" 但是经过fastJSON序列化之后传到前台的时候是: Time: "2016-07-22 10:01:35Z" 经过一番搜索之后发现是时区不一样... 关键发现关于fastJSON的文档比较少、 就连程序集中的注释都少的可怜... 下面自己就一点点摸索吧...
- How...
发现fastJSON的ToJSON方法有两个重载;
第二个参数就是JSONParameters;
再去研究下这个参数、发现里面正好有个UseUTCDateTime...
感觉离成功已经不远了...
JSONParameters jp = new JSONParameters(); jp.UseUTCDateTime = true; return JSON.Instance.ToJSON(db,jp); 查看数据还是老样子... 然后再试下 JSONParameters jp = new JSONParameters(); jp.UseUTCDateTime = false; return JSON.Instance.ToJSON(db,jp); 终于和数据库中的是一样的了...
3.总结...找不到文档的话...自己摸索真的有时候一个很简单的功能也会感觉毫无头绪啊···