我正在使用新的firebase sdk for android并使用真正的数据库功能.当我使用getValue(simple.class)一切都很好.但是当我想解析一个子类的类时,母类的所有属性都是null,并且我有这种类型的错误:
在类uk.edume.edumeapp.TestChild上找不到名称的setter/field
public class TestChild extends TestMother {
private String childAttribute;
public String getChildAttribute() {
return childAttribute;
}
}
public class TestMother {
protected String motherAttribute;
protected String getMotherAttribute() {
return motherAttribute;
}
}
Run Code Online (Sandbox Code Playgroud)
这个功能
snapshot.getValue(TestChild.class);
Run Code Online (Sandbox Code Playgroud)
motherAttribute属性是null,我得到
在类uk.edume.edumeapp.TestChild上找不到关于motherAttribute的setter/field
我解析的Json是:
{
"childAttribute" : "attribute in child class",
"motherAttribute" : "attribute in mother class"
}
Run Code Online (Sandbox Code Playgroud) java android jackson json-deserialization firebase-realtime-database