Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

关于Bean序列化与反序列化Map<String,String>中属性Date类型值为1970年前的问题能否优化? #1772

Closed
xman54 opened this issue Mar 21, 2018 · 1 comment
Labels
Milestone

Comments

@xman54
Copy link

xman54 commented Mar 21, 2018

Map<String,String> hash = JSONObject.parseObject(JSON.toJSONString(bean), new TypeReference<Map<String, String>>(){});
方法可以将Bean序列化成Map<String,String>。

JSONObject.toJavaObject((JSONObject)JSON.toJSON(hash),clazz);
方法反序列化成Bean时,如果属性类型为Date值为1970年以前时间时,会报序列化失败。看了下是com.alibaba.fastjson.util.TypeUils类中castToDate方法第307行代码针对format的处理有些问题,不支持“--355132800000”字符串的处理。

建议307行判断条件改为: if(strVal.indexOf('-',1) != -1){

@wenshao wenshao added the bug label Aug 4, 2018
@wenshao wenshao added this to the 1.2.49 milestone Aug 4, 2018
@wenshao
Copy link
Member

wenshao commented Aug 5, 2018

https://github.com/alibaba/fastjson/releases/tag/1.2.49
问题已修复,请用新版本

@wenshao wenshao closed this as completed Aug 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants