JSON Library getString / optString
for (Flight flight : flights.values()) {
JSONArray flightID = root.optJSONArray(flight.flightId);
if (flightID != null) {
try {
// Get the "planeLat, planeLong" value from the
// flightID
DateTime now = new DateTime();
float planeLat = (float) flightID.optDouble(1);
float planeLong = (float) flightID.getDouble(2);
String planeOrigin = (String) flightID.optString(11);
String planeDestination = (String) flightID.optString(12);
TimeLocation timeLocation = new TimeLocation(
new Location(planeLat, planeLong), now);
flight.addTimeLocation(timeLocation);
flight.setOrigin(planeOrigin);
flight.setDestination(planeDestination);
// Print the coordinates
// println("Lat: " + planeLat + " Long: " +
// planeLong);
// println(planeLat);
println(planeOrigin + " " + planeDestination );
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}