Hier ist die Datenstruktur, die ich einem JAVA-Objekt zuordnen möchte, aber ich kann nicht herausfinden, wie die groupId-Eigenschaft ordnungsgemäß zugeordnet werden kann. Kann mir jemand sagen, wie es gemacht wird? [Unbekanntes Feld bei Zuordnung von Firebase-Datenstruktur zu JAVA-Objekt
Caused by: java.lang.IllegalArgumentException: Unrecognized field "1" (class firebasetest.model.GroupWithGroupId), not marked as ignorable (6 known properties: , "lastGroupId", "hourLimit", "maxLimit", "minLimit", "groupId", "actualLimit"])
08-09 19:04:43.130 8259-8259/firebasetest I/System.out: at [Source: N/A; line: -1, column: -1] (through reference chain: firebasetest.model.GroupWithGroupId["1"])
08-09 19:04:43.130 8259-8259/firebasetest I/System.out: at com.fasterxml.jackson.databind.ObjectMapper._convert(ObjectMapper.java:2615)
und das Java-Objekt:
public class GroupWithGroupId {
public long actualLimit, hourLimit,lastGroupId,maxLimit,minLimit;
public Map<String, Object> groupId = new HashMap<>();
private GroupWithGroupId(){}
public GroupWithGroupId(final long actualLimit, final long hourLimit, final long lastGroupId, final long maxLimit, final long minLimit) {
this.actualLimit = actualLimit;
this.hourLimit = hourLimit;
this.lastGroupId = lastGroupId;
this.maxLimit = maxLimit;
this.minLimit = minLimit;
}
@Exclude
public Map<String, Object> toMap() {
HashMap<String, Object> result = new HashMap<>();
result.put("actualLimit", actualLimit);
result.put("hourLimit", hourLimit);
result.put("lastGroupId", lastGroupId);
result.put("minLimit", minLimit);
result.put("maxLimit", maxLimit);
result.put("groupId", groupId);
return result;
}
}
Vielen Dank für den Vorschlag. Es half, aber ich musste ein bisschen die toMap() Funktion für die richtige Funktion ändern. Siehe meine Lösung unten – SzabK