Why i keep getting the above error when i retrieve out the flight amount?
below is my code for reference.
var requestBooking = (HttpWebRequest)WebRequest.Create("http://www.wego.com/api/flights/pull.html?format=json&apiKey=" + apiKey + "&instanceId=08b2fe006fcd9cd9eff376c87dcf4b05e16a0941&rand=1"); var webResponse = (HttpWebResponse)requestBooking.GetResponse(); if (webResponse.StatusCode == HttpStatusCode.OK) { JavaScriptSerializer json = new JavaScriptSerializer(); StreamReader sr = new StreamReader(webResponse.GetResponseStream()); string resString = sr.ReadToEnd(); RootObject ro = new RootObject(); ro = json.Deserialize<RootObject>(resString); string flightClass = ""; string originCountryCode = ""; string destinationCountryCode = ""; string price = ""; Price p = new Price(); foreach (Itinerary i in ro.response.itineraries) { originCountryCode = i.originCountryCode; destinationCountryCode = i.destinationCountryCode; p = i.price; price = p.totalAmount; //foreach (FlightClass fc in inboundInfo.flightClasses) //{ //} Debug.Write("\n " + originCountryCode + "\n " + destinationCountryCode + price); Label3.Text += "\n From: " + originCountryCode + "\n To: " + destinationCountryCode + price; }
the error point is at price = p.totalAmount;