3
Info类只有构造函数Info(String address),则无法反序列化admin字段,如果加上默认构造函数 public Info() { } 则可以反序列化admin字段
public class Issuexxxx extends TestCase {
public void test_for_issue() throws Exception {
String json = "{\"address\":\"1\",\"admin\":true}";
Info info = JSON.parseObject(json, Info.class);
assertTrue(info.isAdmin());
}
public class Info {
private String address;
private boolean admin;
public Info(String address) {
this.address = address;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public boolean isAdmin() {
return admin;
}
public void setAdmin(boolean admin) {
this.admin = admin;
}
}
}