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.2.21 的SkipTransientField不起作用 #944

Closed
jackmiking opened this issue Dec 8, 2016 · 3 comments
Closed

使用1.2.21 的SkipTransientField不起作用 #944

jackmiking opened this issue Dec 8, 2016 · 3 comments
Milestone

Comments

@jackmiking
Copy link

transient的属性依然被序列化,应该是要忽略掉transient的属性

@wenshao
Copy link
Member

wenshao commented Dec 9, 2016

能提供重现问题的testcase么?

@jackmiking
Copy link
Author

jackmiking commented Dec 12, 2016

public class JsonObjectTest {
    private String name;
    private Integer age;
    private Date time;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
    @Transient
    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }


    public Date getTime() {
        return time;
    }

    public void setTime(Date time) {
        this.time = time;
    }


    public static void main(String[] args) {
        JsonObjectTest jsonObjectTest = new JsonObjectTest();
        jsonObjectTest.setTime(new Date());
        jsonObjectTest.setAge(3);
        jsonObjectTest.setName("abc");
        String s=JSONObject.toJSONString(jsonObjectTest, SerializerFeature.SkipTransientField);
        System.out.println(s);
    }
}

然后输出是:
{"age":3,"name":"abc","time":1481535111675}
age是transient属性来的,应该不能够被序列话出来。

@wenshao wenshao added this to the 1.2.23 milestone Dec 19, 2016
@wenshao
Copy link
Member

wenshao commented Dec 19, 2016

已经支持java.beans.Transient,请等待1.2.23版本

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