Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

对不同时间格式,1.x与2.x版本反序列化对象所得结果不一致[BUG] #1326

Closed
Taogang00 opened this issue Apr 6, 2023 · 4 comments
Labels
bug Something isn't working fixed
Milestone

Comments

@Taogang00
Copy link

问题描述

如标题,fastjson1.x 版本切换到2.x版本时,出现业务对象date属性字段的数据反序列化异常

环境信息

  • OS信息: win10
  • JDK信息: 17
  • 版本信息:2.0.26 最新版本

重现步骤

示例代码:

//可在此输入示例代码
public class DateTest {
    public static class DataDemo {
        private Date createTime;

        public Date getCreateTime() {
            return createTime;
        }

        public void setCreateTime(Date createTime) {
            this.createTime = createTime;
        }
    }

    public static void main(String[] args) {
        String json1 = "{\"createTime\":\"2023-04-06 12:48:11\"}";
        String json2 = "{\"createTime\":\"20230406124811\"}";
        DataDemo fastJson1DataDemo1 = com.alibaba.fastjson.JSONObject.parseObject(json1, DataDemo.class);
        DataDemo fastJson1DataDemo2 = com.alibaba.fastjson.JSONObject.parseObject(json2, DataDemo.class);

        DataDemo fastJson2DataDemo1 = com.alibaba.fastjson2.JSONObject.parseObject(json1, DataDemo.class);
        DataDemo fastJson2DataDemo2 = com.alibaba.fastjson2.JSONObject.parseObject(json2, DataDemo.class);

        System.out.println("ok");
    }
}

image

期待的正确结果

对您期望发生的结果进行清晰简洁的描述。
期望与fastjson 1.x保持一致

@Taogang00 Taogang00 added the bug Something isn't working label Apr 6, 2023
@wenshao
Copy link
Member

wenshao commented Apr 7, 2023

这个要兼容起来还是有些纠结,我再想想哈

@wenshao wenshao added this to the 2.0.28 milestone Apr 7, 2023
@wenshao
Copy link
Member

wenshao commented Apr 13, 2023

https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.28-SNAPSHOT/
问题已修复,请帮忙有2.0.8-SNAPSHOT版本验证,2.0.28版本预计会在周末发布

@wenshao
Copy link
Member

wenshao commented Apr 15, 2023

https://github.com/alibaba/fastjson2/releases/tag/2.0.28
请用新版本

@wenshao wenshao closed this as completed Apr 15, 2023
@Taogang00
Copy link
Author

https://github.com/alibaba/fastjson2/releases/tag/2.0.28 请用新版本

已验证ok,谢谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed
Projects
None yet
Development

No branches or pull requests

2 participants