If I have JSON DATA like:
{
"status":200,
"carList":[
{
"carId":121,
"carName":"Cat",
},
{
"carId":122,
"carName":"Snek",
}
]
}
I want to Use GSON to create the objects by:
Cars cars = gson.fromJson(api.response(), Cars.class);
Using the two classes like this:
Class Cars{
public String status;
public Hashmap<String, Car> carList;
}
Class Car{
public String carId;
public String carName;
}
From what I am reading my problem is putting an object inside of the HashMap.
At the end of the day I need to be able to loop the "carLis" to display it in a table but I am not sure what my approach should be.