設置DTO的變量的是有isXXX的值的,可是使用fastjson序列化後,這幾個變量就不見了。java
{ "cityid":1, "cityname":"上海", "clienttype":"iphone", "glat":139.78120482626642, "glng":35.625721171054344, "msgid":"19142020721848452861509443234119", "overseas":false, "strangeLand":true, "timestamp":1509443234119 }
很奇怪,爲何isXXX序列化後就沒有了呢,而後就去排查,發現默認的setter和getter方法,若是是boolean變量的話默認的get方法用的isxxxjson
public boolean isbackground() { return isbackground; } public void setIsbackground(boolean isbackground) { this.isbackground = isbackground; }
這樣其實就沒有isbackground這個變量的get方法,因此只須要修改isbackground的get方法就能夠了。bash
public boolean getIsbackground() { return isbackground; } public void setIsbackground(boolean isbackground) { this.isbackground = isbackground; }
這樣就行了。。。iphone