I have a Json as below.
{
"currency": "MYR",
"results": [
{
"itineraries": [
{
"outbound": {
"flights": [
{
"departs_at": "2018-06-03T06:25",
"arrives_at": "2018-06-03T07:25",
"origin": {
"airport": "PEN"
},
"destination": {
"airport": "KUL",
"terminal": "M"
},
"marketing_airline": "OD",
"operating_airline": "OD",
"flight_number": "2105",
"aircraft": "738",
"booking_info": {
"travel_class": "ECONOMY",
"booking_code": "Q",
"seats_remaining": 9
}
}
]
},
"inbound": {
"flights": [
{
"departs_at": "2018-06-04T14:10",
"arrives_at": "2018-06-04T15:10",
"origin": {
"airport": "KUL",
"terminal": "M"
},
"destination": {
"airport": "PEN"
},
"marketing_airline": "OD",
"operating_airline": "OD",
"flight_number": "2108",
"aircraft": "739",
"booking_info": {
"travel_class": "ECONOMY",
"booking_code": "O",
"seats_remaining": 5
}
}
]
}
}
],
"fare": {
"total_price": "360.00",
"price_per_adult": {
"total_fare": "360.00",
"tax": "104.00"
},
"restrictions": {
"refundable": false,
"change_penalties": true
}
}
}
]
}
And I use the code below to retrieve the value from the Json. I able to retrieve the "departs_at", "arrives_at", "marketing_airline" but I unable to retrieve the value inside "booking_info".
IOperations _obj = ClsOperations.GetOperations();
string url = "https://api.sandbox.amadeus.com/v1.2/flights/low-fare-search?apikey=" + APIKEY
+ "&origin=" + origin + "&destination=" + destination
+ "&departure_date=" + departureDate + "&return_date=" + returnDate
+ "¤cy=" + currency + "&number_of_results=1";
string json = _obj.GetJsonResult(url);
JToken jToken = JToken.Parse(json);
JArray outBoundFlights = (JArray)jToken.SelectToken("results[0].itineraries[0].outbound.flights");
foreach (JToken obf in outBoundFlights)
{
TravelPlan.Text += "Departs At: " + obf["departs_at"] + "<br/>";
TravelPlan.Text += "Arrives At: " + obf["arrives_at"] + "<br/>";
TravelPlan.Text += "Airline: " + obf["marketing_airline"] + "<br/>";
}
JArray outBoundFlightsBooking = (JArray)jToken.SelectToken("results[0].itineraries[0].outbound.flights.booking_info");
foreach (JToken obfb in outBoundFlightsBooking)
{
TravelPlan.Text += "<br/>";
TravelPlan.Text += "Travel Class: " + obfb["travel_class"] + "<br/>";
TravelPlan.Text += "Seats Remaining: " + obfb["seats_remaining"] + "<br/>";
}
I wish to ask how possible I can retrieve the value inside the booking_info? Thanks for every members here that help.