I am new to Firebase and facing the following issue:
I upload an object(Bill) to my firebase and one attribute is a ArrayList. And it works for uploading.
But when I retrieve the data I get the Error because of the ArrayList
com.firebase.client.FirebaseException: Failed to bounce to type

Main Activity:
Firebase billRef = new Firebase(getResources().getString(R.string.FB_billRef));
Query billQuery = billRef.orderByChild("status").equalTo("Ordered");
billQuery.addChildEventListener(
new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
Bill bill = dataSnapshot.getValue(Bill.class);
}
@Override
public void onChildChanged(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onChildRemoved(DataSnapshot dataSnapshot) {
}
@Override
public void onChildMoved(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onCancelled(FirebaseError firebaseError) {
}
}
);
Bill.class:
public class Bill {
private int billID;
private int tableID;
private int numCustomer;
private String status;
private ArrayList<Order> orders;
public Bill(int billID, int tableID, int numCustomer,String status,ArrayList<Order> orders){
this.billID = billID;
this.tableID = tableID;
this.numCustomer = numCustomer;
this.status = status;
this.orders = orders;
}
public ArrayList<Order> getOrders() {
return orders;
}
public void setOrders(ArrayList<Order> orders){
this.orders = orders;
}
public void addOrder(Order o){}
public void delOrder(int orderID){}
public int getBillID(){return billID;}
public int getTableID(){return tableID;}
public int getNumCustomer(){return numCustomer;}
public String getStatus(){return status;}
}
How can I retrieve this type of firebase object to java object? Thanks a lot!
The only way I had to deal with this is break down the DataSnapshot attributes one by one and get the Order by using the datasnapshot.child("orders").getChildren()
But it is not a good approach to do it. Is it any method that I can get the Bill Object directly?
Listinstead ofArrayList?Caused by).Bill.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@1d5e2d2; line: 1, column: 32] (through reference chain: com.test.Class.Bill["orders"])