FastJSON无法解析自动生成boolean类型的get()和set()方法
原因:FastJSON根据字段的getXXX()方法和setXXXX()方法来解析实体类,但我们通常都会使用开发工具来自动生成get和set方法,但是boolean类型的字段自动生成的不是getXXX()而是isXXX(),这会导致FastJSON解析boolean类型字段时出错。
下面举两个情况:
情况1:对于字段isSuccessful
private boolean isSuccessful;
public boolean isSuccessful() {
return isSuccessful;
}
public void setSuccessful(boolean successful) {
isSuccessful = successful;
}
情况2:对于字段successful
private boolean successful;
public boolean isSuccessful() {
return successful;
}
public void setSuccessful(boolean successful) {
= successful;
}
解决方法之一:可以手动改函数的名称为getIsSuccessful
// 下面这两个是手动设置的get、set方法,以为了能被FastJSON解析
public boolean getIsSuccessful() {
return isSuccessful;
}
public void setIsSuccessful(boolean successful) {
isSuccessful = successful;
}