I am new to C#. I ma trying to create a console weather app. I have fetched JSON data from OpenWeather API which looks like this:
"coord": {
"lon": 27.5667,
"lat": 53.9
},
"weather": [
{
"id": 800,
"main": "Clear",
"description": "clear sky",
"icon": "01d"
}
],
I have called JsonConvert.DeserializeObject<WeatherInfo>(stringResult);
I am able to deserialize the coord part, however the weather part is an array, how do I deserialize it?
private class WeatherInfo
{
public Coord Coord { get; set; }
public Weather Weather { get; set; }
}
private class Weather
{
public readonly string Id;
public readonly string Main;
public readonly string Description;
public readonly string Icon;
public Weather(string lat, string lon, string id, string main, string description, string icon)
{
Id = id;
Main = main;
Description = description;
Icon = icon;
}
}
private class Coord
{
public readonly string Lat;
public readonly string Lon;
public Coord(string lat, string lon)
{
Lat = lat;
Lon = lon;
}
}
```
public Weather[] Weather { get; set; }?