public List <Weather2020Forecast> getForecastList(double latitude, double longitude) { List <Weather2020Forecast> forecastList = new List <Weather2020Forecast>(); Out output = new Out(); restClient.endpoint = weather2020Endpoint.getConditions(latitude, longitude); string response = restClient.makeRequest(); output.outputToConsole($"{response}"); JSONParser <Weather2020Model> jsonParser = new JSONParser <Weather2020Model>(); Weather2020Model deserialisedWeather2020Model = new Weather2020Model(); deserialisedWeather2020Model = new deserializeJSON <List <Weather2020Model> >(response); // public System.Xml.XmlDictionaryString RootName { get; set; } // output.outputToConsole($"{deserialisedWeather2020Model.Group}"); /*foreach (Group forecastMain in deserialisedWeather2020Model) * { * * forecastList.Add(new Weather2020Forecast(forecastMain.startDate, forecastMain.temperatureHighCelcius)); * }*/ return(forecastList); }
public List <Weather2020Forecast> getForecast(string cityName) { List <Weather2020Forecast> forecastList = new List <Weather2020Forecast>(); float locationLongitude = getLocationLongitude(cityName); float locationLatitude = getLocationLatitude(cityName); string response = getResponse(weather2020APIEndpoint.getWeather2020Endpoint(locationLatitude, locationLongitude)); System.Diagnostics.Debug.WriteLine(response); using (JsonParser <Weather2020Model> jsonParser = new JsonParser <Weather2020Model>()) { Weather2020Model weather2020Model = new Weather2020Model(); weather2020Model = jsonParser.parse(response); foreach (Weather2020Model dailyForecast in weather2020Model) { forecastList.Add(new Weather2020Forecast(dailyForecast.startDate, dailyForecast.temperatureHighCelcius, dailyForecast.temperatureLowCelcius)); } } return(forecastList); }