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);
}
}
1条答案
按热度按时间fjnneemd1#
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.annotation.JSONType;
@jsontype(ignores = {"yyy"})
public class Test {
}