I have this JSON returned me from Firebase Realtime Database.
{
"betslipid-4322": {
"amount": 100,
"bets": [
{
"betType": "FT_RESULT_0",
"matchid": "ts-fb",
"odd": 2.4,
"status": "WAITING"
}
],
"status": "WAITING"
},
"betslipid-4323": {
"amount": 7.5,
"bets": [
{
"betType": "FT_RESULT_2",
"matchid": "gs-fb",
"odd": 2.7,
"status": "WAITING"
},
{
"betType": "FT_RESULT_1",
"matchid": "gs-gb",
"odd": 1.3,
"status": "WAITING"
}
],
"status": "WAITING"
}
}
I want to place the attributes of this JSON (including the betSlipID at the beginning) to the following Java class.
public class BetSlip {
private List<Bet> bets;
private Float amount;
private BetStatus status;
private betSlipID;
}
However, I was unable to access the betSlipIDs which are "betslipid-4322" and "betslipid-4323" in this case and I was also unable to convert the JSON to my java class by the following code.
private RestTemplate restTemplate = new RestTemplate();
List<BetSlip> betSlip = restTemplate.getForObject(getDatabaseLink("incomplete-betslips"), ArrayList.class);
Note that I don't know the betSlipIDs when I get the JSON response, so I can't create another class which includes a variable named the incoming betSlipID.