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

JSONType#ignores not working on "isXxx" java bean properties #1146

Open
captmjc opened this issue Apr 14, 2017 · 1 comment
Open

JSONType#ignores not working on "isXxx" java bean properties #1146

captmjc opened this issue Apr 14, 2017 · 1 comment
Labels

Comments

@captmjc
Copy link

captmjc commented Apr 14, 2017

com.alibaba.fastjson.annotation.JSONType#ignores does not work during serializing java beans to JSONs when there are some public boolean isXxx() methods. Test codes are listed below:


@JSONType(ignores = {"xxx", "yyy"})
public class Test {

    public boolean isXxx() {
        return true;
    }
    public boolean getYyy() {
        return true;
    }
    public boolean getZzz() {
        return true;
    }
    public static void main(String[] args) {
        Object json = JSON.toJSON(new Test());
        System.out.println("Expected: {\"zzz\":true}");
        System.out.println("  Actual: " + json);
    }
}
@ljluestc
Copy link

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.annotation.JSONType;

@jsontype(ignores = {"yyy"})
public class Test {

@JSONField(serialize = false)
public boolean isXxx() {
    return true;
}

public boolean getYyy() {
    return true;
}

public boolean getZzz() {
    return true;
}

public static void main(String[] args) {
    Object json = JSON.toJSON(new Test());
    System.out.println("Expected: {\"zzz\":true}");
    System.out.println("  Actual: " + json);
}

}

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

No branches or pull requests

3 participants