java - parsed complex json deserialization with gson separating the objects, lists -


here json rest

{ "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 non refundable booking class : t|cancellation penalty: bookings done subject cancellation penalty levied airlines.<br>in addition airlines cancellation penalty, charge service fee of rs. 50 per passenger cancellations.|date change penalty: in addition airlines date change penalty, charge 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 non refundable booking class : t|cancellation penalty: bookings done subject cancellation penalty levied airlines.<br>in addition airlines cancellation penalty, charge service fee of rs. 50 per passenger cancellations.|date change penalty: in addition airlines date change penalty, charge 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 non refundable booking class : t|cancellation penalty: bookings done subject cancellation penalty levied airlines.<br>in addition airlines cancellation penalty, charge service fee of rs. 50 per passenger cancellations.|date change penalty: in addition airlines date change penalty, charge 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 non refundable booking class : t|cancellation penalty: bookings done subject cancellation penalty levied airlines.<br>in addition airlines cancellation penalty, charge service fee of rs. 50 per passenger cancellations.|date change penalty: in addition airlines date change penalty, charge 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 non refundable booking class : t|cancellation penalty: bookings done subject cancellation penalty levied airlines.<br>in addition airlines cancellation penalty, charge service fee of rs. 50 per passenger cancellations.|date change penalty: in addition airlines date change penalty, charge 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 non refundable booking class : t|cancellation penalty: bookings done subject cancellation penalty levied airlines.<br>in addition airlines cancellation penalty, charge service fee of rs. 50 per passenger cancellations.|date change penalty: in addition airlines date change penalty, charge 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 retrieved"} 

i have created pojo files using on gson.

gson gson = new gson(); data data = gson.fromjson(jsonstring, data.class); 

how store flight numbers individually showing on listview.i guess need this;

list<fightdetails> flight = data.getflightdetails(); flight.getflightnumber(); 

basically when debug on "data" seeing nested fields on debugger. when try call nested class,

flightdetails flightdetails = gson.from(jsonstring, flightdetails.class); 

i getting null flightdetails results.

so have bunch of different flightnumber different flight details json array. how have these flightnumber , show them off merging flightid?

imagine flight provider page. round-trip multistops flight has flight_id , has 2 separate flight_number below flight_details.


Comments