{
"patients": {
"-Kx5vuRqItEF-7kAgVWy": {
"name": "name1",
"age": "27",
"graphData": {
"-K5knK9j8EfUHS7AesFw": {
"date": "16/12/2015",
"graphList": "[...]"
}
}
},
"-Kx5vuRqItEF-7kAgVWy": {
"name": "name1",
"age": "27",
"graphData": {
"-K5knK9j8EfUHS7AesFw": {
"date": "16/12/2015",
"graphList": "[...]"
},
"--K5knNeBFoLrjWnZshfL": {
"date": "12/12/2015",
"graphList": "[...]"
},
}
}
}
}
The PatientView is Java object and it contains another nested Graph Object
public class PatientView {
private String name;
private String age;
private boolean gender;
private float height;
private String phone;
private Object bdate;
private String image;
private ArrayList<Graph> graphData;
public PatientView() {
}
}
Graph Object: which has date and ArrayList object
public class Graph implements Serializable {
private Object graphDate;
private ArrayList<Double> graphList;
// Empty constructor needed for firebase
public Graph() {
}
public Graph(Object graphDate, ArrayList<Double> graphList) {
this.graphDate = graphDate;
this.graphList = graphList;
}
}
and reading the values by firebase addChildEventListen
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
if (dataSnapshot != null && dataSnapshot.getValue() != null) {
PatientView p = dataSnapshot.getValue(PatientView.class);
patients.add(p);
patientIdsFromServer.add(dataSnapshot.getKey());
recyclerView.scrollToPosition(patients.size() - 1);
mAdapter.notifyItemInserted(patients.size() - 1);
}
}
but getting error like
Caused by: com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.util.ArrayList out of START_OBJECT token at [Source: java.io.StringReader@2ced7c6a; line: 1, column: 62] (through reference chain: com.iitb.openmrs.openmrsfinal.ui.Adapter.PatientView["graphData"])
The problem is the when I am pushing data to graphData child it id's are generated so the the schema is not matching with the Graph Object. I searched for is there any way to suppress the id's while reading data not have not found anything.