I'm having trouble understanding why in the example below, the customclass lists(response.results and results) are filled with LinkedHashMaps. I'd expected after parsing the JSON inputstream, the lists just to be full of customclasses, with their classmembers containing the data, straight from JSON. Instead, the Lists come back containing LinkedHashMaps, even though they are type Customclass.
Could anyone explain?
Gson gson = new Gson();
Reader reader = new InputStreamReader(inputStream);
PlacesList response = gson.fromJson(reader, PlacesList.class);
List<Place> results = response.results;
Customclasses used:
public class PlacesList implements Serializable {
@Key
public String status;
@Key
public String error_message;
@Key
public List<Place> results;
}
&
public class Place implements Serializable {
@Key
public String id;
@Key
public String name;
@Key
public String reference;
@Key
public String icon;
@Key
public String vicinity;
@Key
public Geometry geometry;
@Key
public String formatted_address;
@Key
public String formatted_phone_number;
@Override
public String toString() {
return name + " - " + id + " - " + reference;
}
public static class Geometry implements Serializable
{
@Key
public Location location;
}
public static class Location implements Serializable
{
@Key
public double lat;
@Key
public double lng;
}
}