I've to download a Json file with a fields like this:
and so I've made this code:
final Retrofit retrofit = new Retrofit.Builder()
.addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.baseUrl(AirportService.SERVICE_ENDPOINT).build();
AirportService service = retrofit.create(AirportService.class);
service.getAirport()
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Subscriber<List<Airport>>()
{
List<Airport>airps = new ArrayList<Airport>();
@Override
public void onCompleted()
{
}
@Override
public void onError(Throwable e)
{
e.printStackTrace();
}
@Override
public void onNext(List<Airport> airports)
{
for(Airport air : airports)
{
Log.d("latitude",String.valueOf(air.getLatitudeDeg());
//Log.d("iso_c",air.getIsoCountry());
}
});
but the problem is that some fiels are null /0.0: in this case the log is latitude_deg = 0.0
and iso_country = null
. This is the Airport class:
public class Airport {
private double latitudeDeg;
private double longitudeDeg;
private int elevationFt;
private String continent;
private String isoCountry;
/**
*
* @return
* The latitudeDeg
*/
public double getLatitudeDeg() {
return latitudeDeg;
}
/**
*
* @param latitudeDeg
* The latitude_deg
*/
public void setLatitudeDeg(double latitudeDeg) {
this.latitudeDeg = latitudeDeg;
}
/**
*
* @return
* The longitudeDeg
*/
public double getLongitudeDeg() {
return longitudeDeg;
}
/**
*
* @param longitudeDeg
* The longitude_deg
*/
public void setLongitudeDeg(double longitudeDeg) {
this.longitudeDeg = longitudeDeg;
}
/**
*
* @return
* The elevationFt
*/
public int getElevationFt() {
return elevationFt;
}
/**
*
* @param elevationFt
* The elevation_ft
*/
public void setElevationFt(int elevationFt) {
this.elevationFt = elevationFt;
}
/**
*
* @return
* The continent
*/
public String getContinent() {
return continent;
}
/**
*
* @param continent
* The continent
*/
public void setContinent(String continent) {
this.continent = continent;
}
/**
*
* @return
* The isoCountry
*/
public String getIsoCountry() {
return isoCountry;
}
/**
*
* @param isoCountry
* The iso_country
*/
public void setIsoCountry(String isoCountry) {
this.isoCountry = isoCountry;
}
}
that I've generated with JsonToPOJO schema.
What is the error that retrieve me the 0 / null value?
Thank you