getValue(simple.class)
时一切正常。但当我想解析一个是子类的类时,母类的所有属性都是 null
,并且我会有这种类型的错误:
No setter/field for name found on class uk.edume.edumeapp.TestChild
public class TestChild extends TestMother {
private String childAttribute;
public String getChildAttribute() {
return childAttribute;
}
}
public class TestMother {
protected String motherAttribute;
protected String getMotherAttribute() {
return motherAttribute;
}
}
这个函数snapshot.getValue(TestChild.class);
motherAttribute
属性为 null
,并且我得到了:
在类 uk.edume.edumeapp.TestChild 中未找到 motherAttribute 的 setter/field。
我解析的 Json 如下:
{
"childAttribute" : "attribute in child class",
"motherAttribute" : "attribute in mother class"
}