这是我从休息中回来的JSON
{
"tag": "Flight Search Results",
"success": "1",
"xml_filename": "dom_one_20150604172653.xml",
"data": [
{
"depart_from_location": "Bangalore",
"depart_from_location_code": "BLR",
"depart_to_location": "Calicut",
"depart_to_location_code": "CCJ",
"depart_date": "Fri, 05 June 2015",
"return_from_location": "Calicut",
"return_from_location_code": "CCJ",
"return_to_location": "Bangalore",
"return_to_location_code": "BLR",
"return_date": "Sat, 06 June 2015",
"total_onward_flights": 71,
"departure_details": [
{
"flight_id": "arzoo11",
"flights_count": "2",
"flight_details": [
{
"image_filename": "http://live.arzoo.com/FlightWS/image/AirIndia.gif",
"airline_name": "Air India",
"airline_code": "AI",
"flight_number": "608",
"departure_location": "Bangalore ",
"departure_location_code": "BLR",
"departure_date": "2015-06-15",
"departure_time": "21:20:00",
"arrival_location": "Mumbai",
"arrival_location_code": "BOM",
"arrival_date": "2015-06-15",
"arrival_time": "23:00:00",
"travel_time": "1h 40m",
"fare_rules": "This fare is Non Refundable Booking Class : T|Cancellation Penalty: All bookings done are subject to cancellation penalty levied by the airlines.<br>In addition to the airlines cancellation penalty, we charge a service fee of Rs. 50 per passenger for all cancellations.|Date Change Penalty: In addition to the airlines date change penalty, we charge a service fee of Rs. 50 per passenger.|"
},
{
"image_filename": "http://live.arzoo.com/FlightWS/image/AirIndia.gif",
"airline_name": "Air India",
"airline_code": "AI",
"flight_number": "657",
"departure_location": "Mumbai",
"departure_location_code": "BOM",
"departure_date": "2015-06-16",
"departure_time": "10:00:00",
"arrival_location": "Calicut",
"arrival_location_code": "CCJ",
"arrival_date": "2015-06-16",
"arrival_time": "13:05:00",
"travel_time": "3h 5m",
"fare_rules": "This fare is Non Refundable Booking Class : T|Cancellation Penalty: All bookings done are subject to cancellation penalty levied by the airlines.<br>In addition to the airlines cancellation penalty, we charge a service fee of Rs. 50 per passenger for all cancellations.|Date Change Penalty: In addition to the airlines date change penalty, we charge a service fee of Rs. 50 per passenger.|"
}
],
"fare_details": {
"base_fare": "7301",
"airport_tax": "5365",
"service_tax": "46",
"transaction_charge": "0",
"total": "12962",
"total_amount": "12962.00"
}
},
{
"flight_id": "arzoo12",
"flights_count": "2",
"flight_details": [
{
"image_filename": "http://live.arzoo.com/FlightWS/image/AirIndia.gif",
"airline_name": "Air India",
"airline_code": "AI",
"flight_number": "610",
"departure_location": "Bangalore ",
"departure_location_code": "BLR",
"departure_date": "2015-06-15",
"departure_time": "19:00:00",
"arrival_location": "Mumbai",
"arrival_location_code": "BOM",
"arrival_date": "2015-06-15",
"arrival_time": "20:55:00",
"travel_time": "1h 55m",
"fare_rules": "This fare is Non Refundable Booking Class : T|Cancellation Penalty: All bookings done are subject to cancellation penalty levied by the airlines.<br>In addition to the airlines cancellation penalty, we charge a service fee of Rs. 50 per passenger for all cancellations.|Date Change Penalty: In addition to the airlines date change penalty, we charge a service fee of Rs. 50 per passenger.|"
},
{
"image_filename": "http://live.arzoo.com/FlightWS/image/AirIndia.gif",
"airline_name": "Air India",
"airline_code": "AI",
"flight_number": "657",
"departure_location": "Mumbai",
"departure_location_code": "BOM",
"departure_date": "2015-06-16",
"departure_time": "10:00:00",
"arrival_location": "Calicut",
"arrival_location_code": "CCJ",
"arrival_date": "2015-06-16",
"arrival_time": "13:05:00",
"travel_time": "3h 5m",
"fare_rules": "This fare is Non Refundable Booking Class : T|Cancellation Penalty: All bookings done are subject to cancellation penalty levied by the airlines.<br>In addition to the airlines cancellation penalty, we charge a service fee of Rs. 50 per passenger for all cancellations.|Date Change Penalty: In addition to the airlines date change penalty, we charge a service fee of Rs. 50 per passenger.|"
}
],
"fare_details": {
"base_fare": "7301",
"airport_tax": "5365",
"service_tax": "46",
"transaction_charge": "0",
"total": "12962",
"total_amount": "12962.00"
}
},
{
"flight_id": "arzoo13",
"flights_count": "2",
"flight_details": [
{
"image_filename": "http://live.arzoo.com/FlightWS/image/AirIndia.gif",
"airline_name": "Air India",
"airline_code": "AI",
"flight_number": "604",
"departure_location": "Bangalore ",
"departure_location_code": "BLR",
"departure_date": "2015-06-15",
"departure_time": "08:30:00",
"arrival_location": "Mumbai",
"arrival_location_code": "BOM",
"arrival_date": "2015-06-15",
"arrival_time": "10:20:00",
"travel_time": "1h 50m",
"fare_rules": "This fare is Non Refundable Booking Class : T|Cancellation Penalty: All bookings done are subject to cancellation penalty levied by the airlines.<br>In addition to the airlines cancellation penalty, we charge a service fee of Rs. 50 per passenger for all cancellations.|Date Change Penalty: In addition to the airlines date change penalty, we charge a service fee of Rs. 50 per passenger.|"
},
{
"image_filename": "http://live.arzoo.com/FlightWS/image/AirIndia.gif",
"airline_name": "Air India",
"airline_code": "AI",
"flight_number": "657",
"departure_location": "Mumbai",
"departure_location_code": "BOM",
"departure_date": "2015-06-16",
"departure_time": "10:00:00",
"arrival_location": "Calicut",
"arrival_location_code": "CCJ",
"arrival_date": "2015-06-16",
"arrival_time": "13:05:00",
"travel_time": "3h 5m",
"fare_rules": "This fare is Non Refundable Booking Class : T|Cancellation Penalty: All bookings done are subject to cancellation penalty levied by the airlines.<br>In addition to the airlines cancellation penalty, we charge a service fee of Rs. 50 per passenger for all cancellations.|Date Change Penalty: In addition to the airlines date change penalty, we charge a service fee of Rs. 50 per passenger.|"
}
],
"fare_details": {
"base_fare": "7301",
"airport_tax": "5365",
"service_tax": "46",
"transaction_charge": "0",
"total": "12962",
"total_amount": "12962.00"
}
}
],
"total_return_flights": 0,
"return_details": []
}
],
"message": "The flight search results are successfully retrieved"}
我使用on gson创建了POJO文件。
Gson gson = new Gson();
Data data = gson.fromJson(JsonString, Data.class);
如何单独存储所有航班号以便在listview上显示。我想我需要做这样的事情;
List<FightDetails> flight = data.getFlightDetails();
flight.getFlightNumber();
基本上当我调试“数据”时,我看到调试器上的所有嵌套字段。但是,当我尝试调用嵌套类时,
FlightDetails flightdetails = gson.from(jsonString, Flightdetails.class);
我收到了flightdetails结果的空白。
所以我将通过不同的航班细节json数组获得一堆不同的flightNumber。 我如何获得这些flightNumber并将它们与flightId合并显示?
想象一下航班提供商页面。往返多站航班有一个flight_id,并且在flight_details下面有2个单独的flight_number。