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

[BUG]属性字段的isXx()和getXx()同时存在时,序列化输出具有随机性 #549

Closed
zhuyuemufeng opened this issue Jul 12, 2022 · 2 comments
Labels
bug Something isn't working
Milestone

Comments

@zhuyuemufeng
Copy link

问题描述

简要描述您碰到的问题。

环境信息

请填写以下信息:

  • OS信息: window10
  • JDK信息: JDK8
  • 版本信息:2.0.8

重现步骤

测试类:

private class TestObject{
        private String a;
        private String b;
        public String getA() {
            return a;
        }
        public void setA(String a) {
            this.a = a;
        }
        public String getB() {
            return b;
        }
        public void setB(String b) {
            this.b = b;
        }
        public boolean isA(){
            return true;
        }
        public boolean isB(){
            return false;
        }
    }

public static void main(String[] args) {
        TestObject object = new TestObject();
        object.setA("a");
        object.setB("B");
        System.out.println(JSON.toJSONString(object));
    }

输出:
{"a":"a","b":false}

期待的正确结果

{"a":"a","b":“b”}

附加信息

追踪源码发现:
生成FieldWriter时,获取类方法后直接进行遍历生成,未进行排序:
image
对比FastJson1
image

@zhuyuemufeng zhuyuemufeng added the bug Something isn't working label Jul 12, 2022
@wenshao wenshao added this to the 2.0.10 milestone Jul 12, 2022
@wenshao
Copy link
Member

wenshao commented Jul 13, 2022

https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.10-SNAPSHOT/
问题已修复,请用2.0.10-SNAPSHOT版本验证,2.0.10版本预计在7月底发布

@wenshao
Copy link
Member

wenshao commented Jul 23, 2022

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

@wenshao wenshao closed this as completed Jul 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants