static void Get5DayForecast(float lat, float lng, string tempScale) { WebRequest request = WebRequest.Create("http://api.openweathermap.org/data/2.5/forecast?lat=" + lat + "&lon=" + lng + "&appID=408e6e270720aed460c1c391408063f5"); WebResponse response = request.GetResponse(); Stream apiText = response.GetResponseStream(); StreamReader reader = new StreamReader(apiText); serverData = reader.ReadToEnd(); OpenWeatherMap_FiveDay.Welcome results = JsonConvert.DeserializeObject <OpenWeatherMap_FiveDay.Welcome> (serverData); var filteredList = results.List.FirstOrDefault(x => x.Weather.First().Description.Contains("rain")); List <double> testCurrentTempResults = new List <double>(); List <double> testHighTempResults = new List <double>(); List <double> testLowTempResults = new List <double>(); foreach (var list in results.List) { testCurrentTempResults.Add(list.Main.Temp); testHighTempResults.Add(list.Main.TempMax); testLowTempResults.Add(list.Main.TempMin); } Console.WriteLine("TOMORROW'S HIGH: "); Console.WriteLine("TOMORROW'S LOW: "); Console.WriteLine(filteredList.Weather.First().Description); reader.Close(); response.Close(); }
public static string ToJson(this Welcome self) => JsonConvert.SerializeObject(self, OpenWeatherMap_FiveDay.Converter.Settings);