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

JSONField 定义在抽象类中,对子类不起作用。 #744

Closed
wangdao opened this issue Jul 28, 2016 · 2 comments
Closed

JSONField 定义在抽象类中,对子类不起作用。 #744

wangdao opened this issue Jul 28, 2016 · 2 comments
Milestone

Comments

@wangdao
Copy link

wangdao commented Jul 28, 2016

abstract class B {
    private String id;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @JSONField(serialize = false, deserialize = false)
    public abstract String getName();

}

class C extends B {
    private String c;

    private String name;

    public String getC() {
        return c;
    }

    public void setC(String c) {
        this.c = c;
    }

    @Override
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}

 public void test() {

        LoanContractVO loanContractVO = new LoanContractVO();

        C c = new C();
        c.setId("22222222222");
        c.setName("name");
        c.setC("dddddddddddddddddd");

        String json = JSON.toJSONString(c);

        JSONObject obj = JSON.parseObject(json);

        System.out.println(json);
    }

结果:
{"c":"dddddddddddddddddd","id":"22222222222","name":"name"}

期望结果:
{"c":"dddddddddddddddddd","id":"22222222222"}

@wenshao wenshao added this to the 1.2.16 milestone Jul 31, 2016
@wenshao wenshao modified the milestones: 1.2.17, 1.2.16 Aug 12, 2016
@wenshao wenshao modified the milestones: 1.2.18, 1.2.17 Sep 6, 2016
@wenshao wenshao modified the milestones: 1.2.19, 1.2.18, 1.2.20 Oct 15, 2016
@wenshao wenshao modified the milestones: 1.2.21, 1.2.20 Oct 23, 2016
@wenshao wenshao closed this as completed Nov 13, 2016
@wenshao
Copy link
Member

wenshao commented Nov 13, 2016

已经实现,请使用最新的1.2.21版本 https://github.com/alibaba/fastjson/releases/tag/1.2.21

@wangdao
Copy link
Author

wangdao commented Nov 15, 2016

@wenshao 好的,谢谢了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants