This is my logic for getting response in retrofit 2.0
call.enqueue(new Callback<ArrayList<Wallet>>() {
@Override
public void onResponse(Response<ArrayList<Wallet>> response, Retrofit retrofit) {
if (response.isSuccess()) {
// use response data and do some fancy stuff :)
loading.dismiss();
ArrayList<Wallet> orders = response.body();
Utility.displayToast("Wallet size is" + orders.size());
} else {
}
}
});
Data format from rest API is like this:
[
{
"description": "Cashback",
"amount": "20.00",
"type": "1",
"date": "11/03/2016"
},
{
"description": "CASH BACK",
"amount": "12.00",
"type": "1",
"date": "05/03/2016"
}
]
Now they have changes the API and data is coming like this:
{
"error": false,
"wallet": [
{
"description": "Cashback",
"amount": "20.00",
"type": "1",
"date": "11/03/2016"
},
{
"description": "CASH BACK",
"amount": "12.00",
"type": "1",
"date": "05/03/2016"
}
]
}
How to handle object in ONResponse and parse wallet information in array?