none
Cannot deserialize the current JSON object into type System.Collections.Generic.List RRS feed

  • Question

  • Hi,

    Why I keep getting:

    Unhandled Exception:

    Newtonsoft.Json.JsonSerializationException: Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.List`1[Samana.AccuWeather5DaysForecast+RootObject]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.
    To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List<T>) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.
    Path 'Headline', line 1, position 12. occurred

    I have below code and the same working for the current weather but not the 5 days forecast.

    var client = new HttpClient();
    
    client.BaseAddress = new Uri(url);
    
    var response = await client.GetAsync(url);
    
    var json_5days_forecast = await response.Content.ReadAsStringAsync();
    
    var result = JsonConvert.DeserializeObject<List<AccuWeather5DaysForecast.RootObject>>(json_5days_forecast);
    ObservableCollection<AccuWeather5DaysForecast.RootObject> trends = new ObservableCollection<AccuWeather5DaysForecast.RootObject>(result);
    
    ListViewWeather5DaysForecast.ItemsSource = trends;

    and this is the json:

    {
       "Headline":{
          "EffectiveDate":"2019-05-09T07:00:00+04:00",
          "EffectiveEpochDate":1557370800,
          "Severity":7,
          "Text":"Very warm Thursday",
          "Category":"heat",
          "EndDate":"2019-05-09T19:00:00+04:00",
          "EndEpochDate":1557414000,
          "MobileLink":"http://m.accuweather.com/en/ae/al-mateena/323066/extended-weather-forecast/323066?unit=c&lang=en-us",
          "Link":"http://www.accuweather.com/en/ae/al-mateena/323066/daily-weather-forecast/323066?unit=c&lang=en-us"
       },
       "DailyForecasts":[
          {
             "Date":"2019-05-06T07:00:00+04:00",
             "EpochDate":1557111600,
             "Sun":{
                "Rise":"2019-05-06T05:40:00+04:00",
                "EpochRise":1557106800,
                "Set":"2019-05-06T18:52:00+04:00",
                "EpochSet":1557154320
             },
             "Moon":{
                "Rise":"2019-05-06T06:45:00+04:00",
                "EpochRise":1557110700,
                "Set":"2019-05-06T20:20:00+04:00",
                "EpochSet":1557159600,
                "Phase":"WaxingCrescent",
                "Age":2
             },
             "Temperature":{
                "Minimum":{
                   "Value":26.9,
                   "Unit":"C",
                   "UnitType":17
                },
                "Maximum":{
                   "Value":35.8,
                   "Unit":"C",
                   "UnitType":17
                }
             },
             "RealFeelTemperature":{
                "Minimum":{
                   "Value":26.5,
                   "Unit":"C",
                   "UnitType":17
                },
                "Maximum":{
                   "Value":37.7,
                   "Unit":"C",
                   "UnitType":17
                }
             },
             "RealFeelTemperatureShade":{
                "Minimum":{
                   "Value":26.5,
                   "Unit":"C",
                   "UnitType":17
                },
                "Maximum":{
                   "Value":33.9,
                   "Unit":"C",
                   "UnitType":17
                }
             },
             "HoursOfSun":13.2,
             "DegreeDaySummary":{
                "Heating":{
                   "Value":0.0,
                   "Unit":"C",
                   "UnitType":17
                },
                "Cooling":{
                   "Value":13.0,
                   "Unit":"C",
                   "UnitType":17
                }
             },
             "AirAndPollen":[
                {
                   "Name":"AirQuality",
                   "Value":0,
                   "Category":"Good",
                   "CategoryValue":1,
                   "Type":"Ozone"
                },
                {
                   "Name":"Grass",
                   "Value":0,
                   "Category":"Low",
                   "CategoryValue":1
                },
                {
                   "Name":"Mold",
                   "Value":0,
                   "Category":"Low",
                   "CategoryValue":1
                },
                {
                   "Name":"Ragweed",
                   "Value":0,
                   "Category":"Low",
                   "CategoryValue":1
                },
                {
                   "Name":"Tree",
                   "Value":0,
                   "Category":"Low",
                   "CategoryValue":1
                },
                {
                   "Name":"UVIndex",
                   "Value":12,
                   "Category":"Extreme",
                   "CategoryValue":5
                }
             ],
             "Day":{
                "Icon":1,
                "IconPhrase":"Sunny",
                "ShortPhrase":"Plenty of sunshine; pleasant",
                "LongPhrase":"Plenty of sunshine; pleasant",
                "PrecipitationProbability":0,
                "ThunderstormProbability":0,
                "RainProbability":0,
                "SnowProbability":0,
                "IceProbability":0,
                "Wind":{
                   "Speed":{
                      "Value":18.5,
                      "Unit":"km/h",
                      "UnitType":7
                   },
                   "Direction":{
                      "Degrees":256,
                      "Localized":"WSW",
                      "English":"WSW"
                   }
                },
                "WindGust":{
                   "Speed":{
                      "Value":40.7,
                      "Unit":"km/h",
                      "UnitType":7
                   },
                   "Direction":{
                      "Degrees":263,
                      "Localized":"W",
                      "English":"W"
                   }
                },
                "TotalLiquid":{
                   "Value":0.0,
                   "Unit":"mm",
                   "UnitType":3
                },
                "Rain":{
                   "Value":0.0,
                   "Unit":"mm",
                   "UnitType":3
                },
                "Snow":{
                   "Value":0.0,
                   "Unit":"cm",
                   "UnitType":4
                },
                "Ice":{
                   "Value":0.0,
                   "Unit":"mm",
                   "UnitType":3
                },
                "HoursOfPrecipitation":0.0,
                "HoursOfRain":0.0,
                "HoursOfSnow":0.0,
                "HoursOfIce":0.0,
                "CloudCover":0
             },
             "Night":{
                "Icon":33,
                "IconPhrase":"Clear",
                "ShortPhrase":"Clear",
                "LongPhrase":"Clear",
                "PrecipitationProbability":0,
                "ThunderstormProbability":0,
                "RainProbability":0,
                "SnowProbability":0,
                "IceProbability":0,
                "Wind":{
                   "Speed":{
                      "Value":13.0,
                      "Unit":"km/h",
                      "UnitType":7
                   },
                   "Direction":{
                      "Degrees":212,
                      "Localized":"SSW",
                      "English":"SSW"
                   }
                },
                "WindGust":{
                   "Speed":{
                      "Value":18.5,
                      "Unit":"km/h",
                      "UnitType":7
                   },
                   "Direction":{
                      "Degrees":227,
                      "Localized":"SW",
                      "English":"SW"
                   }
                },
                "TotalLiquid":{
                   "Value":0.0,
                   "Unit":"mm",
                   "UnitType":3
                },
                "Rain":{
                   "Value":0.0,
                   "Unit":"mm",
                   "UnitType":3
                },
                "Snow":{
                   "Value":0.0,
                   "Unit":"cm",
                   "UnitType":4
                },
                "Ice":{
                   "Value":0.0,
                   "Unit":"mm",
                   "UnitType":3
                },
                "HoursOfPrecipitation":0.0,
                "HoursOfRain":0.0,
                "HoursOfSnow":0.0,
                "HoursOfIce":0.0,
                "CloudCover":0
             },
             "Sources":[
                "AccuWeather"
             ],
             "MobileLink":"http://m.accuweather.com/en/ae/al-mateena/323066/daily-weather-forecast/323066?day=1&unit=c&lang=en-us",
             "Link":"http://www.accuweather.com/en/ae/al-mateena/323066/daily-weather-forecast/323066?day=1&unit=c&lang=en-us"
          },
          {
             "Date":"2019-05-07T07:00:00+04:00",
             "EpochDate":1557198000,
             "Sun":{
                "Rise":"2019-05-07T05:39:00+04:00",
                "EpochRise":1557193140,
                "Set":"2019-05-07T18:52:00+04:00",
                "EpochSet":1557240720
             },
             "Moon":{
                "Rise":"2019-05-07T07:31:00+04:00",
                "EpochRise":1557199860,
                "Set":"2019-05-07T21:20:00+04:00",
                "EpochSet":1557249600,
                "Phase":"WaxingCrescent",
                "Age":3
             },
             "Temperature":{
                "Minimum":{
                   "Value":25.2,
                   "Unit":"C",
                   "UnitType":17
                },
                "Maximum":{
                   "Value":35.4,
                   "Unit":"C",
                   "UnitType":17
                }
             },
             "RealFeelTemperature":{
                "Minimum":{
                   "Value":25.2,
                   "Unit":"C",
                   "UnitType":17
                },
                "Maximum":{
                   "Value":37.0,
                   "Unit":"C",
                   "UnitType":17
                }
             },
             "RealFeelTemperatureShade":{
                "Minimum":{
                   "Value":25.2,
                   "Unit":"C",
                   "UnitType":17
                },
                "Maximum":{
                   "Value":33.5,
                   "Unit":"C",
                   "UnitType":17
                }
             },
             "HoursOfSun":13.2,
             "DegreeDaySummary":{
                "Heating":{
                   "Value":0.0,
                   "Unit":"C",
                   "UnitType":17
                },
                "Cooling":{
                   "Value":12.0,
                   "Unit":"C",
                   "UnitType":17
                }
             },
             "AirAndPollen":[
                {
                   "Name":"AirQuality",
                   "Value":0,
                   "Category":"Good",
                   "CategoryValue":1,
                   "Type":"Ozone"
                },
                {
                   "Name":"Grass",
                   "Value":0,
                   "Category":"Low",
                   "CategoryValue":1
                },
                {
                   "Name":"Mold",
                   "Value":0,
                   "Category":"Low",
                   "CategoryValue":1
                },
                {
                   "Name":"Ragweed",
                   "Value":0,
                   "Category":"Low",
                   "CategoryValue":1
                },
                {
                   "Name":"Tree",
                   "Value":0,
                   "Category":"Low",
                   "CategoryValue":1
                },
                {
                   "Name":"UVIndex",
                   "Value":12,
                   "Category":"Extreme",
                   "CategoryValue":5
                }
             ],
             "Day":{
                "Icon":1,
                "IconPhrase":"Sunny",
                "ShortPhrase":"Plenty of sunshine",
                "LongPhrase":"Plenty of sunshine",
                "PrecipitationProbability":0,
                "ThunderstormProbability":0,
                "RainProbability":0,
                "SnowProbability":0,
                "IceProbability":0,
                "Wind":{
                   "Speed":{
                      "Value":20.4,
                      "Unit":"km/h",
                      "UnitType":7
                   },
                   "Direction":{
                      "Degrees":244,
                      "Localized":"WSW",
                      "English":"WSW"
                   }
                },
                "WindGust":{
                   "Speed":{
                      "Value":25.9,
                      "Unit":"km/h",
                      "UnitType":7
                   },
                   "Direction":{
                      "Degrees":263,
                      "Localized":"W",
                      "English":"W"
                   }
                },
                "TotalLiquid":{
                   "Value":0.0,
                   "Unit":"mm",
                   "UnitType":3
                },
                "Rain":{
                   "Value":0.0,
                   "Unit":"mm",
                   "UnitType":3
                },
                "Snow":{
                   "Value":0.0,
                   "Unit":"cm",
                   "UnitType":4
                },
                "Ice":{
                   "Value":0.0,
                   "Unit":"mm",
                   "UnitType":3
                },
                "HoursOfPrecipitation":0.0,
                "HoursOfRain":0.0,
                "HoursOfSnow":0.0,
                "HoursOfIce":0.0,
                "CloudCover":0
             },
             "Night":{
                "Icon":33,
                "IconPhrase":"Clear",
                "ShortPhrase":"Clear",
                "LongPhrase":"Clear",
                "PrecipitationProbability":0,
                "ThunderstormProbability":0,
                "RainProbability":0,
                "SnowProbability":0,
                "IceProbability":0,
                "Wind":{
                   "Speed":{
                      "Value":13.0,
                      "Unit":"km/h",
                      "UnitType":7
                   },
                   "Direction":{
                      "Degrees":212,
                      "Localized":"SSW",
                      "English":"SSW"
                   }
                },
                "WindGust":{
                   "Speed":{
                      "Value":18.5,
                      "Unit":"km/h",
                      "UnitType":7
                   },
                   "Direction":{
                      "Degrees":251,
                      "Localized":"WSW",
                      "English":"WSW"
                   }
                },
                "TotalLiquid":{
                   "Value":0.0,
                   "Unit":"mm",
                   "UnitType":3
                },
                "Rain":{
                   "Value":0.0,
                   "Unit":"mm",
                   "UnitType":3
                },
                "Snow":{
                   "Value":0.0,
                   "Unit":"cm",
                   "UnitType":4
                },
                "Ice":{
                   "Value":0.0,
                   "Unit":"mm",
                   "UnitType":3
                },
                "HoursOfPrecipitation":0.0,
                "HoursOfRain":0.0,
                "HoursOfSnow":0.0,
                "HoursOfIce":0.0,
                "CloudCover":6
             },
             "Sources":[
                "AccuWeather"
             ],
             "MobileLink":"http://m.accuweather.com/en/ae/al-mateena/323066/daily-weather-forecast/323066?day=2&unit=c&lang=en-us",
             "Link":"http://www.accuweather.com/en/ae/al-mateena/323066/daily-weather-forecast/323066?day=2&unit=c&lang=en-us"
          },
          {
             "Date":"2019-05-08T07:00:00+04:00",
             "EpochDate":1557284400,
             "Sun":{
                "Rise":"2019-05-08T05:38:00+04:00",
                "EpochRise":1557279480,
                "Set":"2019-05-08T18:53:00+04:00",
                "EpochSet":1557327180
             },
             "Moon":{
                "Rise":"2019-05-08T08:22:00+04:00",
                "EpochRise":1557289320,
                "Set":"2019-05-08T22:20:00+04:00",
                "EpochSet":1557339600,
                "Phase":"WaxingCrescent",
                "Age":4
             },
             "Temperature":{
                "Minimum":{
                   "Value":25.8,
                   "Unit":"C",
                   "UnitType":17
                },
                "Maximum":{
                   "Value":35.4,
                   "Unit":"C",
                   "UnitType":17
                }
             },
             "RealFeelTemperature":{
                "Minimum":{
                   "Value":25.9,
                   "Unit":"C",
                   "UnitType":17
                },
                "Maximum":{
                   "Value":38.3,
                   "Unit":"C",
                   "UnitType":17
                }
             },
             "RealFeelTemperatureShade":{
                "Minimum":{
                   "Value":25.9,
                   "Unit":"C",
                   "UnitType":17
                },
                "Maximum":{
                   "Value":33.9,
                   "Unit":"C",
                   "UnitType":17
                }
             },
             "HoursOfSun":9.6,
             "DegreeDaySummary":{
                "Heating":{
                   "Value":0.0,
                   "Unit":"C",
                   "UnitType":17
                },
                "Cooling":{
                   "Value":13.0,
                   "Unit":"C",
                   "UnitType":17
                }
             },
             "AirAndPollen":[
                {
                   "Name":"AirQuality",
                   "Value":0,
                   "Category":"Good",
                   "CategoryValue":1,
                   "Type":"Ozone"
                },
                {
                   "Name":"Grass",
                   "Value":0,
                   "Category":"Low",
                   "CategoryValue":1
                },
                {
                   "Name":"Mold",
                   "Value":0,
                   "Category":"Low",
                   "CategoryValue":1
                },
                {
                   "Name":"Ragweed",
                   "Value":0,
                   "Category":"Low",
                   "CategoryValue":1
                },
                {
                   "Name":"Tree",
                   "Value":0,
                   "Category":"Low",
                   "CategoryValue":1
                },
                {
                   "Name":"UVIndex",
                   "Value":12,
                   "Category":"Extreme",
                   "CategoryValue":5
                }
             ],
             "Day":{
                "Icon":3,
                "IconPhrase":"Partly sunny",
                "ShortPhrase":"Sun mixing with clouds",
                "LongPhrase":"Sunshine mixing with some clouds",
                "PrecipitationProbability":0,
                "ThunderstormProbability":0,
                "RainProbability":0,
                "SnowProbability":0,
                "IceProbability":0,
                "Wind":{
                   "Speed":{
                      "Value":13.0,
                      "Unit":"km/h",
                      "UnitType":7
                   },
                   "Direction":{
                      "Degrees":239,
                      "Localized":"WSW",
                      "English":"WSW"
                   }
                },
                "WindGust":{
                   "Speed":{
                      "Value":22.2,
                      "Unit":"km/h",
                      "UnitType":7
                   },
                   "Direction":{
                      "Degrees":262,
                      "Localized":"W",
                      "English":"W"
                   }
                },
                "TotalLiquid":{
                   "Value":0.0,
                   "Unit":"mm",
                   "UnitType":3
                },
                "Rain":{
                   "Value":0.0,
                   "Unit":"mm",
                   "UnitType":3
                },
                "Snow":{
                   "Value":0.0,
                   "Unit":"cm",
                   "UnitType":4
                },
                "Ice":{
                   "Value":0.0,
                   "Unit":"mm",
                   "UnitType":3
                },
                "HoursOfPrecipitation":0.0,
                "HoursOfRain":0.0,
                "HoursOfSnow":0.0,
                "HoursOfIce":0.0,
                "CloudCover":32
             },
             "Night":{
                "Icon":33,
                "IconPhrase":"Clear",
                "ShortPhrase":"Clear",
                "LongPhrase":"Clear",
                "PrecipitationProbability":0,
                "ThunderstormProbability":0,
                "RainProbability":0,
                "SnowProbability":0,
                "IceProbability":0,
                "Wind":{
                   "Speed":{
                      "Value":5.6,
                      "Unit":"km/h",
                      "UnitType":7
                   },
                   "Direction":{
                      "Degrees":194,
                      "Localized":"SSW",
                      "English":"SSW"
                   }
                },
                "WindGust":{
                   "Speed":{
                      "Value":16.7,
                      "Unit":"km/h",
                      "UnitType":7
                   },
                   "Direction":{
                      "Degrees":291,
                      "Localized":"WNW",
                      "English":"WNW"
                   }
                },
                "TotalLiquid":{
                   "Value":0.0,
                   "Unit":"mm",
                   "UnitType":3
                },
                "Rain":{
                   "Value":0.0,
                   "Unit":"mm",
                   "UnitType":3
                },
                "Snow":{
                   "Value":0.0,
                   "Unit":"cm",
                   "UnitType":4
                },
                "Ice":{
                   "Value":0.0,
                   "Unit":"mm",
                   "UnitType":3
                },
                "HoursOfPrecipitation":0.0,
                "HoursOfRain":0.0,
                "HoursOfSnow":0.0,
                "HoursOfIce":0.0,
                "CloudCover":7
             },
             "Sources":[
                "AccuWeather"
             ],
             "MobileLink":"http://m.accuweather.com/en/ae/al-mateena/323066/daily-weather-forecast/323066?day=3&unit=c&lang=en-us",
             "Link":"http://www.accuweather.com/en/ae/al-mateena/323066/daily-weather-forecast/323066?day=3&unit=c&lang=en-us"
          },
          {
             "Date":"2019-05-09T07:00:00+04:00",
             "EpochDate":1557370800,
             "Sun":{
                "Rise":"2019-05-09T05:38:00+04:00",
                "EpochRise":1557365880,
                "Set":"2019-05-09T18:53:00+04:00",
                "EpochSet":1557413580
             },
             "Moon":{
                "Rise":"2019-05-09T09:18:00+04:00",
                "EpochRise":1557379080,
                "Set":"2019-05-09T23:18:00+04:00",
                "EpochSet":1557429480,
                "Phase":"WaxingCrescent",
                "Age":5
             },
             "Temperature":{
                "Minimum":{
                   "Value":26.8,
                   "Unit":"C",
                   "UnitType":17
                },
                "Maximum":{
                   "Value":38.4,
                   "Unit":"C",
                   "UnitType":17
                }
             },
             "RealFeelTemperature":{
                "Minimum":{
                   "Value":26.4,
                   "Unit":"C",
                   "UnitType":17
                },
                "Maximum":{
                   "Value":41.0,
                   "Unit":"C",
                   "UnitType":17
                }
             },
             "RealFeelTemperatureShade":{
                "Minimum":{
                   "Value":26.4,
                   "Unit":"C",
                   "UnitType":17
                },
                "Maximum":{
                   "Value":36.9,
                   "Unit":"C",
                   "UnitType":17
                }
             },
             "HoursOfSun":12.6,
             "DegreeDaySummary":{
                "Heating":{
                   "Value":0.0,
                   "Unit":"C",
                   "UnitType":17
                },
                "Cooling":{
                   "Value":15.0,
                   "Unit":"C",
                   "UnitType":17
                }
             },
             "AirAndPollen":[
                {
                   "Name":"AirQuality",
                   "Value":0,
                   "Category":"Good",
                   "CategoryValue":1,
                   "Type":"Ozone"
                },
                {
                   "Name":"Grass",
                   "Value":0,
                   "Category":"Low",
                   "CategoryValue":1
                },
                {
                   "Name":"Mold",
                   "Value":0,
                   "Category":"Low",
                   "CategoryValue":1
                },
                {
                   "Name":"Ragweed",
                   "Value":0,
                   "Category":"Low",
                   "CategoryValue":1
                },
                {
                   "Name":"Tree",
                   "Value":0,
                   "Category":"Low",
                   "CategoryValue":1
                },
                {
                   "Name":"UVIndex",
                   "Value":12,
                   "Category":"Extreme",
                   "CategoryValue":5
                }
             ],
             "Day":{
                "Icon":1,
                "IconPhrase":"Sunny",
                "ShortPhrase":"Sunshine; very warm",
                "LongPhrase":"Sunshine; very warm",
                "PrecipitationProbability":0,
                "ThunderstormProbability":0,
                "RainProbability":0,
                "SnowProbability":0,
                "IceProbability":0,
                "Wind":{
                   "Speed":{
                      "Value":13.0,
                      "Unit":"km/h",
                      "UnitType":7
                   },
                   "Direction":{
                      "Degrees":44,
                      "Localized":"NE",
                      "English":"NE"
                   }
                },
                "WindGust":{
                   "Speed":{
                      "Value":24.1,
                      "Unit":"km/h",
                      "UnitType":7
                   },
                   "Direction":{
                      "Degrees":351,
                      "Localized":"N",
                      "English":"N"
                   }
                },
                "TotalLiquid":{
                   "Value":0.0,
                   "Unit":"mm",
                   "UnitType":3
                },
                "Rain":{
                   "Value":0.0,
                   "Unit":"mm",
                   "UnitType":3
                },
                "Snow":{
                   "Value":0.0,
                   "Unit":"cm",
                   "UnitType":4
                },
                "Ice":{
                   "Value":0.0,
                   "Unit":"mm",
                   "UnitType":3
                },
                "HoursOfPrecipitation":0.0,
                "HoursOfRain":0.0,
                "HoursOfSnow":0.0,
                "HoursOfIce":0.0,
                "CloudCover":5
             },
             "Night":{
                "Icon":33,
                "IconPhrase":"Clear",
                "ShortPhrase":"Clear; very warm",
                "LongPhrase":"Clear; very warm",
                "PrecipitationProbability":0,
                "ThunderstormProbability":0,
                "RainProbability":0,
                "SnowProbability":0,
                "IceProbability":0,
                "Wind":{
                   "Speed":{
                      "Value":7.4,
                      "Unit":"km/h",
                      "UnitType":7
                   },
                   "Direction":{
                      "Degrees":67,
                      "Localized":"ENE",
                      "English":"ENE"
                   }
                },
                "WindGust":{
                   "Speed":{
                      "Value":20.4,
                      "Unit":"km/h",
                      "UnitType":7
                   },
                   "Direction":{
                      "Degrees":17,
                      "Localized":"NNE",
                      "English":"NNE"
                   }
                },
                "TotalLiquid":{
                   "Value":0.0,
                   "Unit":"mm",
                   "UnitType":3
                },
                "Rain":{
                   "Value":0.0,
                   "Unit":"mm",
                   "UnitType":3
                },
                "Snow":{
                   "Value":0.0,
                   "Unit":"cm",
                   "UnitType":4
                },
                "Ice":{
                   "Value":0.0,
                   "Unit":"mm",
                   "UnitType":3
                },
                "HoursOfPrecipitation":0.0,
                "HoursOfRain":0.0,
                "HoursOfSnow":0.0,
                "HoursOfIce":0.0,
                "CloudCover":3
             },
             "Sources":[
                "AccuWeather"
             ],
             "MobileLink":"http://m.accuweather.com/en/ae/al-mateena/323066/daily-weather-forecast/323066?day=4&unit=c&lang=en-us",
             "Link":"http://www.accuweather.com/en/ae/al-mateena/323066/daily-weather-forecast/323066?day=4&unit=c&lang=en-us"
          },
          {
             "Date":"2019-05-10T07:00:00+04:00",
             "EpochDate":1557457200,
             "Sun":{
                "Rise":"2019-05-10T05:37:00+04:00",
                "EpochRise":1557452220,
                "Set":"2019-05-10T18:54:00+04:00",
                "EpochSet":1557500040
             },
             "Moon":{
                "Rise":"2019-05-10T10:18:00+04:00",
                "EpochRise":1557469080,
                "Set":"2019-05-11T00:12:00+04:00",
                "EpochSet":1557519120,
                "Phase":"WaxingCrescent",
                "Age":6
             },
             "Temperature":{
                "Minimum":{
                   "Value":27.2,
                   "Unit":"C",
                   "UnitType":17
                },
                "Maximum":{
                   "Value":37.5,
                   "Unit":"C",
                   "UnitType":17
                }
             },
             "RealFeelTemperature":{
                "Minimum":{
                   "Value":27.5,
                   "Unit":"C",
                   "UnitType":17
                },
                "Maximum":{
                   "Value":40.4,
                   "Unit":"C",
                   "UnitType":17
                }
             },
             "RealFeelTemperatureShade":{
                "Minimum":{
                   "Value":27.5,
                   "Unit":"C",
                   "UnitType":17
                },
                "Maximum":{
                   "Value":36.0,
                   "Unit":"C",
                   "UnitType":17
                }
             },
             "HoursOfSun":13.2,
             "DegreeDaySummary":{
                "Heating":{
                   "Value":0.0,
                   "Unit":"C",
                   "UnitType":17
                },
                "Cooling":{
                   "Value":14.0,
                   "Unit":"C",
                   "UnitType":17
                }
             },
             "AirAndPollen":[
                {
                   "Name":"AirQuality",
                   "Value":0,
                   "Category":"Good",
                   "CategoryValue":1,
                   "Type":"Ozone"
                },
                {
                   "Name":"Grass",
                   "Value":0,
                   "Category":"Low",
                   "CategoryValue":1
                },
                {
                   "Name":"Mold",
                   "Value":0,
                   "Category":"Low",
                   "CategoryValue":1
                },
                {
                   "Name":"Ragweed",
                   "Value":0,
                   "Category":"Low",
                   "CategoryValue":1
                },
                {
                   "Name":"Tree",
                   "Value":0,
                   "Category":"Low",
                   "CategoryValue":1
                },
                {
                   "Name":"UVIndex",
                   "Value":12,
                   "Category":"Extreme",
                   "CategoryValue":5
                }
             ],
             "Day":{
                "Icon":1,
                "IconPhrase":"Sunny",
                "ShortPhrase":"Plenty of sunshine; very warm",
                "LongPhrase":"Plenty of sunshine; very warm",
                "PrecipitationProbability":0,
                "ThunderstormProbability":0,
                "RainProbability":0,
                "SnowProbability":0,
                "IceProbability":0,
                "Wind":{
                   "Speed":{
                      "Value":13.0,
                      "Unit":"km/h",
                      "UnitType":7
                   },
                   "Direction":{
                      "Degrees":355,
                      "Localized":"N",
                      "English":"N"
                   }
                },
                "WindGust":{
                   "Speed":{
                      "Value":24.1,
                      "Unit":"km/h",
                      "UnitType":7
                   },
                   "Direction":{
                      "Degrees":331,
                      "Localized":"NNW",
                      "English":"NNW"
                   }
                },
                "TotalLiquid":{
                   "Value":0.0,
                   "Unit":"mm",
                   "UnitType":3
                },
                "Rain":{
                   "Value":0.0,
                   "Unit":"mm",
                   "UnitType":3
                },
                "Snow":{
                   "Value":0.0,
                   "Unit":"cm",
                   "UnitType":4
                },
                "Ice":{
                   "Value":0.0,
                   "Unit":"mm",
                   "UnitType":3
                },
                "HoursOfPrecipitation":0.0,
                "HoursOfRain":0.0,
                "HoursOfSnow":0.0,
                "HoursOfIce":0.0,
                "CloudCover":0
             },
             "Night":{
                "Icon":33,
                "IconPhrase":"Clear",
                "ShortPhrase":"Clear; very warm",
                "LongPhrase":"Clear; very warm",
                "PrecipitationProbability":0,
                "ThunderstormProbability":0,
                "RainProbability":0,
                "SnowProbability":0,
                "IceProbability":0,
                "Wind":{
                   "Speed":{
                      "Value":5.6,
                      "Unit":"km/h",
                      "UnitType":7
                   },
                   "Direction":{
                      "Degrees":226,
                      "Localized":"SW",
                      "English":"SW"
                   }
                },
                "WindGust":{
                   "Speed":{
                      "Value":18.5,
                      "Unit":"km/h",
                      "UnitType":7
                   },
                   "Direction":{
                      "Degrees":319,
                      "Localized":"NW",
                      "English":"NW"
                   }
                },
                "TotalLiquid":{
                   "Value":0.0,
                   "Unit":"mm",
                   "UnitType":3
                },
                "Rain":{
                   "Value":0.0,
                   "Unit":"mm",
                   "UnitType":3
                },
                "Snow":{
                   "Value":0.0,
                   "Unit":"cm",
                   "UnitType":4
                },
                "Ice":{
                   "Value":0.0,
                   "Unit":"mm",
                   "UnitType":3
                },
                "HoursOfPrecipitation":0.0,
                "HoursOfRain":0.0,
                "HoursOfSnow":0.0,
                "HoursOfIce":0.0,
                "CloudCover":0
             },
             "Sources":[
                "AccuWeather"
             ],
             "MobileLink":"http://m.accuweather.com/en/ae/al-mateena/323066/daily-weather-forecast/323066?day=5&unit=c&lang=en-us",
             "Link":"http://www.accuweather.com/en/ae/al-mateena/323066/daily-weather-forecast/323066?day=5&unit=c&lang=en-us"
          }
       ]
    }

    Thanks,

    Jassim

    Monday, May 6, 2019 10:47 PM

All replies

  • I ran the json back through a json to c# converter.  I am not going to include all the classes generated but the root object returns an List of DailyForecast.   You only need to into a root object not a List of root objects

    public class RootObject
    {
        public Headline Headline { get; set; }
        public List<DailyForecast> DailyForecasts { get; set; }
    }

    var result = JsonConvert.DeserializeObject<AccuWeather5DaysForecast.RootObject>(json_5days_forecast);
    


    Monday, May 6, 2019 11:44 PM
  • but when I try that I get:

    cannot convert from 'Samana.AccuWeather5DaysForecast.RootObject' to 'System.Collections.Generic.IEnumerable<Samana.AccuWeather5DaysForecast.RootObject>'

    Monday, May 6, 2019 11:50 PM
  • Here are the classes you can deserialize into

    public class Headline
    {
        public DateTime EffectiveDate { get; set; }
        public int EffectiveEpochDate { get; set; }
        public int Severity { get; set; }
        public string Text { get; set; }
        public string Category { get; set; }
        public DateTime EndDate { get; set; }
        public int EndEpochDate { get; set; }
        public string MobileLink { get; set; }
        public string Link { get; set; }
    }

    public class Sun
    {
        public DateTime Rise { get; set; }
        public int EpochRise { get; set; }
        public DateTime Set { get; set; }
        public int EpochSet { get; set; }
    }

    public class Moon
    {
        public DateTime Rise { get; set; }
        public int EpochRise { get; set; }
        public DateTime Set { get; set; }
        public int EpochSet { get; set; }
        public string Phase { get; set; }
        public int Age { get; set; }
    }

    public class Minimum
    {
        public double Value { get; set; }
        public string Unit { get; set; }
        public int UnitType { get; set; }
    }

    public class Maximum
    {
        public double Value { get; set; }
        public string Unit { get; set; }
        public int UnitType { get; set; }
    }

    public class Temperature
    {
        public Minimum Minimum { get; set; }
        public Maximum Maximum { get; set; }
    }

    public class Minimum2
    {
        public double Value { get; set; }
        public string Unit { get; set; }
        public int UnitType { get; set; }
    }

    public class Maximum2
    {
        public double Value { get; set; }
        public string Unit { get; set; }
        public int UnitType { get; set; }
    }

    public class RealFeelTemperature
    {
        public Minimum2 Minimum { get; set; }
        public Maximum2 Maximum { get; set; }
    }

    public class Minimum3
    {
        public double Value { get; set; }
        public string Unit { get; set; }
        public int UnitType { get; set; }
    }

    public class Maximum3
    {
        public double Value { get; set; }
        public string Unit { get; set; }
        public int UnitType { get; set; }
    }

    public class RealFeelTemperatureShade
    {
        public Minimum3 Minimum { get; set; }
        public Maximum3 Maximum { get; set; }
    }

    public class Heating
    {
        public double Value { get; set; }
        public string Unit { get; set; }
        public int UnitType { get; set; }
    }

    public class Cooling
    {
        public double Value { get; set; }
        public string Unit { get; set; }
        public int UnitType { get; set; }
    }

    public class DegreeDaySummary
    {
        public Heating Heating { get; set; }
        public Cooling Cooling { get; set; }
    }

    public class AirAndPollen
    {
        public string Name { get; set; }
        public int Value { get; set; }
        public string Category { get; set; }
        public int CategoryValue { get; set; }
        public string Type { get; set; }
    }

    public class Speed
    {
        public double Value { get; set; }
        public string Unit { get; set; }
        public int UnitType { get; set; }
    }

    public class Direction
    {
        public int Degrees { get; set; }
        public string Localized { get; set; }
        public string English { get; set; }
    }

    public class Wind
    {
        public Speed Speed { get; set; }
        public Direction Direction { get; set; }
    }

    public class Speed2
    {
        public double Value { get; set; }
        public string Unit { get; set; }
        public int UnitType { get; set; }
    }

    public class Direction2
    {
        public int Degrees { get; set; }
        public string Localized { get; set; }
        public string English { get; set; }
    }

    public class WindGust
    {
        public Speed2 Speed { get; set; }
        public Direction2 Direction { get; set; }
    }

    public class TotalLiquid
    {
        public double Value { get; set; }
        public string Unit { get; set; }
        public int UnitType { get; set; }
    }

    public class Rain
    {
        public double Value { get; set; }
        public string Unit { get; set; }
        public int UnitType { get; set; }
    }

    public class Snow
    {
        public double Value { get; set; }
        public string Unit { get; set; }
        public int UnitType { get; set; }
    }

    public class Ice
    {
        public double Value { get; set; }
        public string Unit { get; set; }
        public int UnitType { get; set; }
    }

    public class Day
    {
        public int Icon { get; set; }
        public string IconPhrase { get; set; }
        public string ShortPhrase { get; set; }
        public string LongPhrase { get; set; }
        public int PrecipitationProbability { get; set; }
        public int ThunderstormProbability { get; set; }
        public int RainProbability { get; set; }
        public int SnowProbability { get; set; }
        public int IceProbability { get; set; }
        public Wind Wind { get; set; }
        public WindGust WindGust { get; set; }
        public TotalLiquid TotalLiquid { get; set; }
        public Rain Rain { get; set; }
        public Snow Snow { get; set; }
        public Ice Ice { get; set; }
        public double HoursOfPrecipitation { get; set; }
        public double HoursOfRain { get; set; }
        public double HoursOfSnow { get; set; }
        public double HoursOfIce { get; set; }
        public int CloudCover { get; set; }
    }

    public class Speed3
    {
        public double Value { get; set; }
        public string Unit { get; set; }
        public int UnitType { get; set; }
    }

    public class Direction3
    {
        public int Degrees { get; set; }
        public string Localized { get; set; }
        public string English { get; set; }
    }

    public class Wind2
    {
        public Speed3 Speed { get; set; }
        public Direction3 Direction { get; set; }
    }

    public class Speed4
    {
        public double Value { get; set; }
        public string Unit { get; set; }
        public int UnitType { get; set; }
    }

    public class Direction4
    {
        public int Degrees { get; set; }
        public string Localized { get; set; }
        public string English { get; set; }
    }

    public class WindGust2
    {
        public Speed4 Speed { get; set; }
        public Direction4 Direction { get; set; }
    }

    public class TotalLiquid2
    {
        public double Value { get; set; }
        public string Unit { get; set; }
        public int UnitType { get; set; }
    }

    public class Rain2
    {
        public double Value { get; set; }
        public string Unit { get; set; }
        public int UnitType { get; set; }
    }

    public class Snow2
    {
        public double Value { get; set; }
        public string Unit { get; set; }
        public int UnitType { get; set; }
    }

    public class Ice2
    {
        public double Value { get; set; }
        public string Unit { get; set; }
        public int UnitType { get; set; }
    }

    public class Night
    {
        public int Icon { get; set; }
        public string IconPhrase { get; set; }
        public string ShortPhrase { get; set; }
        public string LongPhrase { get; set; }
        public int PrecipitationProbability { get; set; }
        public int ThunderstormProbability { get; set; }
        public int RainProbability { get; set; }
        public int SnowProbability { get; set; }
        public int IceProbability { get; set; }
        public Wind2 Wind { get; set; }
        public WindGust2 WindGust { get; set; }
        public TotalLiquid2 TotalLiquid { get; set; }
        public Rain2 Rain { get; set; }
        public Snow2 Snow { get; set; }
        public Ice2 Ice { get; set; }
        public double HoursOfPrecipitation { get; set; }
        public double HoursOfRain { get; set; }
        public double HoursOfSnow { get; set; }
        public double HoursOfIce { get; set; }
        public int CloudCover { get; set; }
    }

    public class DailyForecast
    {
        public DateTime Date { get; set; }
        public int EpochDate { get; set; }
        public Sun Sun { get; set; }
        public Moon Moon { get; set; }
        public Temperature Temperature { get; set; }
        public RealFeelTemperature RealFeelTemperature { get; set; }
        public RealFeelTemperatureShade RealFeelTemperatureShade { get; set; }
        public double HoursOfSun { get; set; }
        public DegreeDaySummary DegreeDaySummary { get; set; }
        public List<AirAndPollen> AirAndPollen { get; set; }
        public Day Day { get; set; }
        public Night Night { get; set; }
        public List<string> Sources { get; set; }
        public string MobileLink { get; set; }
        public string Link { get; set; }
    }

    public class RootObject
    {
        public Headline Headline { get; set; }
        public List<DailyForecast> DailyForecasts { get; set; }
    }

    Tuesday, May 7, 2019 12:01 AM
  • it's the same thing which I have

    I am getting the error on this line for the result

    ObservableCollection<AccuWeather5DaysForecast.RootObject> trends = new ObservableCollection<AccuWeather5DaysForecast.RootObject>(result);

    Tuesday, May 7, 2019 12:08 AM
  • Hi Jassim Rahma,

    Thank you for posting here.

    For your question, Visual Studio provide a tool to generate the classes. You could try the steps below.

    First, copy your json data. And then, click Edit in VS menu> Paste Special> Paste JSON As Classes. It will generate the classes correctly.


    Here are the classes.

    public class RootObject
        {
            public Headline Headline { get; set; }
            public Dailyforecast[] DailyForecasts { get; set; }
        }
    
        public class Headline
        {
            public DateTime EffectiveDate { get; set; }
            public int EffectiveEpochDate { get; set; }
            public int Severity { get; set; }
            public string Text { get; set; }
            public string Category { get; set; }
            public DateTime EndDate { get; set; }
            public int EndEpochDate { get; set; }
            public string MobileLink { get; set; }
            public string Link { get; set; }
        }
    
        public class Dailyforecast
        {
            public DateTime Date { get; set; }
            public int EpochDate { get; set; }
            public Sun Sun { get; set; }
            public Moon Moon { get; set; }
            public Temperature Temperature { get; set; }
            public Realfeeltemperature RealFeelTemperature { get; set; }
            public Realfeeltemperatureshade RealFeelTemperatureShade { get; set; }
            public float HoursOfSun { get; set; }
            public Degreedaysummary DegreeDaySummary { get; set; }
            public Airandpollen[] AirAndPollen { get; set; }
            public Day Day { get; set; }
            public Night Night { get; set; }
            public string[] Sources { get; set; }
            public string MobileLink { get; set; }
            public string Link { get; set; }
        }
    
        public class Sun
        {
            public DateTime Rise { get; set; }
            public int EpochRise { get; set; }
            public DateTime Set { get; set; }
            public int EpochSet { get; set; }
        }
    
        public class Moon
        {
            public DateTime Rise { get; set; }
            public int EpochRise { get; set; }
            public DateTime Set { get; set; }
            public int EpochSet { get; set; }
            public string Phase { get; set; }
            public int Age { get; set; }
        }
    
        public class Temperature
        {
            public Minimum Minimum { get; set; }
            public Maximum Maximum { get; set; }
        }
    
        public class Minimum
        {
            public float Value { get; set; }
            public string Unit { get; set; }
            public int UnitType { get; set; }
        }
    
        public class Maximum
        {
            public float Value { get; set; }
            public string Unit { get; set; }
            public int UnitType { get; set; }
        }
    
        public class Realfeeltemperature
        {
            public Minimum1 Minimum { get; set; }
            public Maximum1 Maximum { get; set; }
        }
    
        public class Minimum1
        {
            public float Value { get; set; }
            public string Unit { get; set; }
            public int UnitType { get; set; }
        }
    
        public class Maximum1
        {
            public float Value { get; set; }
            public string Unit { get; set; }
            public int UnitType { get; set; }
        }
    
        public class Realfeeltemperatureshade
        {
            public Minimum2 Minimum { get; set; }
            public Maximum2 Maximum { get; set; }
        }
    
        public class Minimum2
        {
            public float Value { get; set; }
            public string Unit { get; set; }
            public int UnitType { get; set; }
        }
    
        public class Maximum2
        {
            public float Value { get; set; }
            public string Unit { get; set; }
            public int UnitType { get; set; }
        }
    
        public class Degreedaysummary
        {
            public Heating Heating { get; set; }
            public Cooling Cooling { get; set; }
        }
    
        public class Heating
        {
            public float Value { get; set; }
            public string Unit { get; set; }
            public int UnitType { get; set; }
        }
    
        public class Cooling
        {
            public float Value { get; set; }
            public string Unit { get; set; }
            public int UnitType { get; set; }
        }
    
        public class Day
        {
            public int Icon { get; set; }
            public string IconPhrase { get; set; }
            public string ShortPhrase { get; set; }
            public string LongPhrase { get; set; }
            public int PrecipitationProbability { get; set; }
            public int ThunderstormProbability { get; set; }
            public int RainProbability { get; set; }
            public int SnowProbability { get; set; }
            public int IceProbability { get; set; }
            public Wind Wind { get; set; }
            public Windgust WindGust { get; set; }
            public Totalliquid TotalLiquid { get; set; }
            public Rain Rain { get; set; }
            public Snow Snow { get; set; }
            public Ice Ice { get; set; }
            public float HoursOfPrecipitation { get; set; }
            public float HoursOfRain { get; set; }
            public float HoursOfSnow { get; set; }
            public float HoursOfIce { get; set; }
            public int CloudCover { get; set; }
        }
    
        public class Wind
        {
            public Speed Speed { get; set; }
            public Direction Direction { get; set; }
        }
    
        public class Speed
        {
            public float Value { get; set; }
            public string Unit { get; set; }
            public int UnitType { get; set; }
        }
    
        public class Direction
        {
            public int Degrees { get; set; }
            public string Localized { get; set; }
            public string English { get; set; }
        }
    
        public class Windgust
        {
            public Speed1 Speed { get; set; }
            public Direction1 Direction { get; set; }
        }
    
        public class Speed1
        {
            public float Value { get; set; }
            public string Unit { get; set; }
            public int UnitType { get; set; }
        }
    
        public class Direction1
        {
            public int Degrees { get; set; }
            public string Localized { get; set; }
            public string English { get; set; }
        }
    
        public class Totalliquid
        {
            public float Value { get; set; }
            public string Unit { get; set; }
            public int UnitType { get; set; }
        }
    
        public class Rain
        {
            public float Value { get; set; }
            public string Unit { get; set; }
            public int UnitType { get; set; }
        }
    
        public class Snow
        {
            public float Value { get; set; }
            public string Unit { get; set; }
            public int UnitType { get; set; }
        }
    
        public class Ice
        {
            public float Value { get; set; }
            public string Unit { get; set; }
            public int UnitType { get; set; }
        }
    
        public class Night
        {
            public int Icon { get; set; }
            public string IconPhrase { get; set; }
            public string ShortPhrase { get; set; }
            public string LongPhrase { get; set; }
            public int PrecipitationProbability { get; set; }
            public int ThunderstormProbability { get; set; }
            public int RainProbability { get; set; }
            public int SnowProbability { get; set; }
            public int IceProbability { get; set; }
            public Wind1 Wind { get; set; }
            public Windgust1 WindGust { get; set; }
            public Totalliquid1 TotalLiquid { get; set; }
            public Rain1 Rain { get; set; }
            public Snow1 Snow { get; set; }
            public Ice1 Ice { get; set; }
            public float HoursOfPrecipitation { get; set; }
            public float HoursOfRain { get; set; }
            public float HoursOfSnow { get; set; }
            public float HoursOfIce { get; set; }
            public int CloudCover { get; set; }
        }
    
        public class Wind1
        {
            public Speed2 Speed { get; set; }
            public Direction2 Direction { get; set; }
        }
    
        public class Speed2
        {
            public float Value { get; set; }
            public string Unit { get; set; }
            public int UnitType { get; set; }
        }
    
        public class Direction2
        {
            public int Degrees { get; set; }
            public string Localized { get; set; }
            public string English { get; set; }
        }
    
        public class Windgust1
        {
            public Speed3 Speed { get; set; }
            public Direction3 Direction { get; set; }
        }
    
        public class Speed3
        {
            public float Value { get; set; }
            public string Unit { get; set; }
            public int UnitType { get; set; }
        }
    
        public class Direction3
        {
            public int Degrees { get; set; }
            public string Localized { get; set; }
            public string English { get; set; }
        }
    
        public class Totalliquid1
        {
            public float Value { get; set; }
            public string Unit { get; set; }
            public int UnitType { get; set; }
        }
    
        public class Rain1
        {
            public float Value { get; set; }
            public string Unit { get; set; }
            public int UnitType { get; set; }
        }
    
        public class Snow1
        {
            public float Value { get; set; }
            public string Unit { get; set; }
            public int UnitType { get; set; }
        }
    
        public class Ice1
        {
            public float Value { get; set; }
            public string Unit { get; set; }
            public int UnitType { get; set; }
        }
    
        public class Airandpollen
        {
            public string Name { get; set; }
            public int Value { get; set; }
            public string Category { get; set; }
            public int CategoryValue { get; set; }
            public string Type { get; set; }
        }

    But, with the code you provided I get the error on the line of result like below. Do you get the same error?

    They use different type. 

    We use the code below to deserialize json data.

     var result = JsonConvert.DeserializeObject<RootObject>(json_5days_forecast);
     But what does the code below doing for?
    ObservableCollection<RootObject> trends = new ObservableCollection<RootObject>(result);

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Tuesday, May 7, 2019 6:11 AM
    Moderator
  • I never used the Paste as JSON class but it's very useful.. Thanks.

    I tried it now and pasted my json class but still getting error..

    the ObservableCollection is the item source for my ListView

    var result = JsonConvert.DeserializeObject<AccuWeather5DaysForecast.RootObject>(json_5days_forecast);
    
    ObservableCollection<AccuWeather5DaysForecast.RootObject> trends = new ObservableCollection<AccuWeather5DaysForecast.RootObject>(result);
    
    ListViewWeather5DaysForecast.ItemsSource = trends;
    

    The error I am getting using this is:

    cannot convert from 'Samana.AccuWeather5DaysForecast.Rootobject' to 'System.Collections.Generic.IEnumerable<Samana.AccuWeather5DaysForecast.Rootobject>'


    Tuesday, May 7, 2019 3:56 PM
  • Hi Jassim Rahma,

    Based on my test, I guess the error is caused by you json data. 

    I test the code with another json data, it works well. I do not have the same client code, hence I use json data directly for test.

      

    class Program
        {
            public static void Main(string[] args)
            {

    string json = @"[ { 'ID': 1, 'title': 'XO', 'artist': 'EDEN', 'featuredArtist': '', 'releaseYear': 2015, 'album': 'i think you think too much of me', 'streamURL': 'spotify' }, { 'ID': 2, 'title': 'Humble', 'artist': 'Kendrick Lamar', 'featuredArtist': '', 'releaseYear': 2017, 'album': 'DAMN', 'streamURL': 'spotify' } ]"; var result = JsonConvert.DeserializeObject<List<Rootobject5>>(json); ObservableCollection<Rootobject5> trends = new ObservableCollection<Rootobject5>(result); } } public class Rootobject5 { public Class1[] Property1 { get; set; } } public class Class1 { public int ID { get; set; } public string title { get; set; } public string artist { get; set; } public string featuredArtist { get; set; } public int releaseYear { get; set; } public string album { get; set; } public string streamURL { get; set; } }

     

    Based on my test , I get the same complier like yours. 

    But when I check the json data in another way, the error will show the error screenshot in my previous reply. On my test, the json data you provided is not a correct json format.

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, May 8, 2019 3:01 AM
    Moderator
  • Thanks Wendy..

    But Where could be the problem? If it's a problem with json then for sure AccuWeather should have been informed by their many clients and it was rectified by now.. I am just assuming here :)

    Here is my full code with the URL:

    private async void GetDailyForecast()
    {
        ListViewWeatherDailyForecast.IsVisible = false;
        loadingWeatherDailyForecast.IsVisible = true;
    
        var location_data = await GetLocation();
    
        string url = "http://dataservice.accuweather.com/forecasts/v1/daily/5day/" + location_key + "?apikey=" + api_key + "&details=true&metric=true"; ;
    
        var client = new HttpClient();
    
        client.BaseAddress = new Uri(url);
    
        var response = await client.GetAsync(url);
    
        var json_daily_forecast = await response.Content.ReadAsStringAsync();
    
        var result_daily_forecast = JsonConvert.DeserializeObject<List<AccuWeatherDailyForecast.RootObject>>(json_daily_forecast);
    
        ObservableCollection<AccuWeatherDailyForecast.RootObject> trends = new ObservableCollection<AccuWeatherDailyForecast.RootObject>(result_daily_forecast);
    
        ListViewWeatherDailyForecast.ItemsSource = trends;
    
        loadingWeatherDailyForecast.IsVisible = false;
    
        ListViewWeatherDailyForecast.IsVisible = true;
    }
    

    and this is the URL:

    http://dataservice.accuweather.com/forecasts/v1/daily/5day/323066?apikey=IEWqqL6jVXpH11TEVrKNuIVhkqPfJpKB&details=true&metric=true

    Thanks,

    Jassim

    Friday, May 10, 2019 2:07 AM
  • and I have the same error when working on Google Places API too

    Newtonsoft.Json.JsonSerializationException: Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.List`1[Samana.GooglePlaces+RootObject]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly. To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List<T>) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object. Path 'html_attributions', line 2, position 24.

    using System;
    using System.Collections.Generic;
    using System.Text;
    
    namespace Samana
    {
        class GooglePlaces
        {
            public class Location
            {
                public double lat { get; set; }
                public double lng { get; set; }
            }
    
            public class Northeast
            {
                public double lat { get; set; }
                public double lng { get; set; }
            }
    
            public class Southwest
            {
                public double lat { get; set; }
                public double lng { get; set; }
            }
    
            public class Viewport
            {
                public Northeast northeast { get; set; }
                public Southwest southwest { get; set; }
            }
    
            public class Geometry
            {
                public Location location { get; set; }
                public Viewport viewport { get; set; }
            }
    
            public class OpeningHours
            {
                public bool open_now { get; set; }
            }
    
            public class Photo
            {
                public int height { get; set; }
                public List<string> html_attributions { get; set; }
                public string photo_reference { get; set; }
                public int width { get; set; }
            }
    
            public class PlusCode
            {
                public string compound_code { get; set; }
                public string global_code { get; set; }
            }
    
            public class Result
            {
                public Geometry geometry { get; set; }
                public string icon { get; set; }
                public string id { get; set; }
                public string name { get; set; }
                public OpeningHours opening_hours { get; set; }
                public List<Photo> photos { get; set; }
                public string place_id { get; set; }
                public PlusCode plus_code { get; set; }
                public double rating { get; set; }
                public string reference { get; set; }
                public string scope { get; set; }
                public List<string> types { get; set; }
                public int user_ratings_total { get; set; }
                public string vicinity { get; set; }
                public int? price_level { get; set; }
            }
    
            public class RootObject
            {
                public List<object> html_attributions { get; set; }
                public string next_page_token { get; set; }
                public List<Result> results { get; set; }
                public string status { get; set; }
            }
        }
    }
    

    Sunday, May 12, 2019 12:23 AM
  • Hi Jassim Rahma,

    I test with all the json data.

    I get the same result. I get the error below with your json data. But if I use another json data, it works well. The error is caused by the json data.

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, May 14, 2019 8:46 AM
    Moderator
  • Yeah I was able to get the Google Place API but still having problem with the daily forecast API from AccuWeather.

    I'll contact them and revert back here

    Thank you so much Wendy

    Tuesday, May 14, 2019 4:22 PM
  • This is the reply I received from AccuWeather today

    Tuesday, May 14, 2019 9:24 PM
  • Hi Jassim Rahma,

    If you really want to make it works well, you need to do some change with the json data. I am not sure whether it effect you results.

    You need to get your json data first and store them to a string and add "[ ]".

    I make a sample for your reference.

    using Newtonsoft.Json;
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using System.Data;
    using System.Data.OleDb;
    using System.Globalization;
    using System.Linq;
    using System.Reflection;
    using System.Runtime.InteropServices;
    using System.Text;
    using System.Threading.Tasks;
    using System.Xml.Linq;
    
    namespace ConsoleApp
    {
        class Program
        {
            public static void Main(string[] args)
            {
    
                string json = @"[{'Headline':{'EffectiveDate':'2019-05-16T19:00:00+04:00','EffectiveEpochDate':1558018800,'Severity':7,'Text':'Warm Thursday night','Category':'heat','EndDate':'2019-05-17T07:00:00+04:00','EndEpochDate':1558062000,'MobileLink':'http://m.accuweather.com/en/ae/al-mateena/323066/extended-weather-forecast/323066?unit=c&lang=en-us','Link':'http://www.accuweather.com/en/ae/al-mateena/323066/daily-weather-forecast/323066?unit=c&lang=en-us'},'DailyForecasts':[{'Date':'2019-05-15T07:00:00+04:00','EpochDate':1557889200,'Sun':{'Rise':'2019-05-15T05:34:00+04:00','EpochRise':1557884040,'Set':'2019-05-15T18:56:00+04:00','EpochSet':1557932160},'Moon':{'Rise':'2019-05-15T15:31:00+04:00','EpochRise':1557919860,'Set':'2019-05-16T03:52:00+04:00','EpochSet':1557964320,'Phase':'WaxingGibbous','Age':11},'Temperature':{'Minimum':{'Value':25.3,'Unit':'C','UnitType':17},'Maximum':{'Value':36.0,'Unit':'C','UnitType':17}},'RealFeelTemperature':{'Minimum':{'Value':25.7,'Unit':'C','UnitType':17},'Maximum':{'Value':38.3,'Unit':'C','UnitType':17}},'RealFeelTemperatureShade':{'Minimum':{'Value':25.7,'Unit':'C','UnitType':17},'Maximum':{'Value':34.3,'Unit':'C','UnitType':17}},'HoursOfSun':13.4,'DegreeDaySummary':{'Heating':{'Value':0.0,'Unit':'C','UnitType':17},'Cooling':{'Value':13.0,'Unit':'C','UnitType':17}},'AirAndPollen':[{'Name':'AirQuality','Value':0,'Category':'Good','CategoryValue':1,'Type':'Ozone'},{'Name':'Grass','Value':0,'Category':'Low','CategoryValue':1},{'Name':'Mold','Value':0,'Category':'Low','CategoryValue':1},{'Name':'Ragweed','Value':0,'Category':'Low','CategoryValue':1},{'Name':'Tree','Value':0,'Category':'Low','CategoryValue':1},{'Name':'UVIndex','Value':12,'Category':'Extreme','CategoryValue':5}],'Day':{'Icon':1,'IconPhrase':'Sunny','ShortPhrase':'Plenty of sunshine','LongPhrase':'Plenty of sunshine','PrecipitationProbability':0,'ThunderstormProbability':0,'RainProbability':0,'SnowProbability':0,'IceProbability':0,'Wind':{'Speed':{'Value':14.8,'Unit':'km/h','UnitType':7},'Direction':{'Degrees':260,'Localized':'W','English':'W'}},'WindGust':{'Speed':{'Value':20.4,'Unit':'km/h','UnitType':7},'Direction':{'Degrees':224,'Localized':'SW','English':'SW'}},'TotalLiquid':{'Value':0.0,'Unit':'mm','UnitType':3},'Rain':{'Value':0.0,'Unit':'mm','UnitType':3},'Snow':{'Value':0.0,'Unit':'cm','UnitType':4},'Ice':{'Value':0.0,'Unit':'mm','UnitType':3},'HoursOfPrecipitation':0.0,'HoursOfRain':0.0,'HoursOfSnow':0.0,'HoursOfIce':0.0,'CloudCover':0},'Night':{'Icon':33,'IconPhrase':'Clear','ShortPhrase':'Clear','LongPhrase':'Clear','PrecipitationProbability':0,'ThunderstormProbability':0,'RainProbability':0,'SnowProbability':0,'IceProbability':0,'Wind':{'Speed':{'Value':3.7,'Unit':'km/h','UnitType':7},'Direction':{'Degrees':202,'Localized':'SSW','English':'SSW'}},'WindGust':{'Speed':{'Value':16.7,'Unit':'km/h','UnitType':7},'Direction':{'Degrees':263,'Localized':'W','English':'W'}},'TotalLiquid':{'Value':0.0,'Unit':'mm','UnitType':3},'Rain':{'Value':0.0,'Unit':'mm','UnitType':3},'Snow':{'Value':0.0,'Unit':'cm','UnitType':4},'Ice':{'Value':0.0,'Unit':'mm','UnitType':3},'HoursOfPrecipitation':0.0,'HoursOfRain':0.0,'HoursOfSnow':0.0,'HoursOfIce':0.0,'CloudCover':0},'Sources':['AccuWeather'],'MobileLink':'http://m.accuweather.com/en/ae/al-mateena/323066/daily-weather-forecast/323066?day=1&unit=c&lang=en-us','Link':'http://www.accuweather.com/en/ae/al-mateena/323066/daily-weather-forecast/323066?day=1&unit=c&lang=en-us'},{'Date':'2019-05-16T07:00:00+04:00','EpochDate':1557975600,'Sun':{'Rise':'2019-05-16T05:34:00+04:00','EpochRise':1557970440,'Set':'2019-05-16T18:57:00+04:00','EpochSet':1558018620},'Moon':{'Rise':'2019-05-16T16:32:00+04:00','EpochRise':1558009920,'Set':'2019-05-17T04:32:00+04:00','EpochSet':1558053120,'Phase':'WaxingGibbous','Age':12},'Temperature':{'Minimum':{'Value':27.1,'Unit':'C','UnitType':17},'Maximum':{'Value':37.0,'Unit':'C','UnitType':17}},'RealFeelTemperature':{'Minimum':{'Value':26.8,'Unit':'C','UnitType':17},'Maximum':{'Value':39.2,'Unit':'C','UnitType':17}},'RealFeelTemperatureShade':{'Minimum':{'Value':26.8,'Unit':'C','UnitType':17},'Maximum':{'Value':35.3,'Unit':'C','UnitType':17}},'HoursOfSun':13.4,'DegreeDaySummary':{'Heating':{'Value':0.0,'Unit':'C','UnitType':17},'Cooling':{'Value':14.0,'Unit':'C','UnitType':17}},'AirAndPollen':[{'Name':'AirQuality','Value':0,'Category':'Good','CategoryValue':1,'Type':'Ozone'},{'Name':'Grass','Value':0,'Category':'Low','CategoryValue':1},{'Name':'Mold','Value':0,'Category':'Low','CategoryValue':1},{'Name':'Ragweed','Value':0,'Category':'Low','CategoryValue':1},{'Name':'Tree','Value':0,'Category':'Low','CategoryValue':1},{'Name':'UVIndex','Value':12,'Category':'Extreme','CategoryValue':5}],'Day':{'Icon':1,'IconPhrase':'Sunny','ShortPhrase':'Plenty of sunshine','LongPhrase':'Plenty of sunshine','PrecipitationProbability':0,'ThunderstormProbability':0,'RainProbability':0,'SnowProbability':0,'IceProbability':0,'Wind':{'Speed':{'Value':9.3,'Unit':'km/h','UnitType':7},'Direction':{'Degrees':272,'Localized':'W','English':'W'}},'WindGust':{'Speed':{'Value':22.2,'Unit':'km/h','UnitType':7},'Direction':{'Degrees':335,'Localized':'NNW','English':'NNW'}},'TotalLiquid':{'Value':0.0,'Unit':'mm','UnitType':3},'Rain':{'Value':0.0,'Unit':'mm','UnitType':3},'Snow':{'Value':0.0,'Unit':'cm','UnitType':4},'Ice':{'Value':0.0,'Unit':'mm','UnitType':3},'HoursOfPrecipitation':0.0,'HoursOfRain':0.0,'HoursOfSnow':0.0,'HoursOfIce':0.0,'CloudCover':0},'Night':{'Icon':33,'IconPhrase':'Clear','ShortPhrase':'Clear; very warm','LongPhrase':'Clear; very warm','PrecipitationProbability':0,'ThunderstormProbability':0,'RainProbability':0,'SnowProbability':0,'IceProbability':0,'Wind':{'Speed':{'Value':5.6,'Unit':'km/h','UnitType':7},'Direction':{'Degrees':71,'Localized':'ENE','English':'ENE'}},'WindGust':{'Speed':{'Value':14.8,'Unit':'km/h','UnitType':7},'Direction':{'Degrees':341,'Localized':'NNW','English':'NNW'}},'TotalLiquid':{'Value':0.0,'Unit':'mm','UnitType':3},'Rain':{'Value':0.0,'Unit':'mm','UnitType':3},'Snow':{'Value':0.0,'Unit':'cm','UnitType':4},'Ice':{'Value':0.0,'Unit':'mm','UnitType':3},'HoursOfPrecipitation':0.0,'HoursOfRain':0.0,'HoursOfSnow':0.0,'HoursOfIce':0.0,'CloudCover':0},'Sources':['AccuWeather'],'MobileLink':'http://m.accuweather.com/en/ae/al-mateena/323066/daily-weather-forecast/323066?day=2&unit=c&lang=en-us','Link':'http://www.accuweather.com/en/ae/al-mateena/323066/daily-weather-forecast/323066?day=2&unit=c&lang=en-us'},{'Date':'2019-05-17T07:00:00+04:00','EpochDate':1558062000,'Sun':{'Rise':'2019-05-17T05:33:00+04:00','EpochRise':1558056780,'Set':'2019-05-17T18:57:00+04:00','EpochSet':1558105020},'Moon':{'Rise':'2019-05-17T17:33:00+04:00','EpochRise':1558099980,'Set':'2019-05-18T05:13:00+04:00','EpochSet':1558141980,'Phase':'WaxingGibbous','Age':13},'Temperature':{'Minimum':{'Value':27.8,'Unit':'C','UnitType':17},'Maximum':{'Value':38.6,'Unit':'C','UnitType':17}},'RealFeelTemperature':{'Minimum':{'Value':27.0,'Unit':'C','UnitType':17},'Maximum':{'Value':40.4,'Unit':'C','UnitType':17}},'RealFeelTemperatureShade':{'Minimum':{'Value':27.0,'Unit':'C','UnitType':17},'Maximum':{'Value':36.9,'Unit':'C','UnitType':17}},'HoursOfSun':12.8,'DegreeDaySummary':{'Heating':{'Value':0.0,'Unit':'C','UnitType':17},'Cooling':{'Value':15.0,'Unit':'C','UnitType':17}},'AirAndPollen':[{'Name':'AirQuality','Value':0,'Category':'Good','CategoryValue':1,'Type':'Ozone'},{'Name':'Grass','Value':0,'Category':'Low','CategoryValue':1},{'Name':'Mold','Value':0,'Category':'Low','CategoryValue':1},{'Name':'Ragweed','Value':0,'Category':'Low','CategoryValue':1},{'Name':'Tree','Value':0,'Category':'Low','CategoryValue':1},{'Name':'UVIndex','Value':12,'Category':'Extreme','CategoryValue':5}],'Day':{'Icon':1,'IconPhrase':'Sunny','ShortPhrase':'Plenty of sunshine; very warm','LongPhrase':'Plenty of sunshine; very warm','PrecipitationProbability':0,'ThunderstormProbability':0,'RainProbability':0,'SnowProbability':0,'IceProbability':0,'Wind':{'Speed':{'Value':13.0,'Unit':'km/h','UnitType':7},'Direction':{'Degrees':9,'Localized':'N','English':'N'}},'WindGust':{'Speed':{'Value':25.9,'Unit':'km/h','UnitType':7},'Direction':{'Degrees':343,'Localized':'NNW','English':'NNW'}},'TotalLiquid':{'Value':0.0,'Unit':'mm','UnitType':3},'Rain':{'Value':0.0,'Unit':'mm','UnitType':3},'Snow':{'Value':0.0,'Unit':'cm','UnitType':4},'Ice':{'Value':0.0,'Unit':'mm','UnitType':3},'HoursOfPrecipitation':0.0,'HoursOfRain':0.0,'HoursOfSnow':0.0,'HoursOfIce':0.0,'CloudCover':1},'Night':{'Icon':34,'IconPhrase':'Mostly clear','ShortPhrase':'Mainly clear; very warm','LongPhrase':'Mainly clear; very warm','PrecipitationProbability':0,'ThunderstormProbability':0,'RainProbability':0,'SnowProbability':0,'IceProbability':0,'Wind':{'Speed':{'Value':9.3,'Unit':'km/h','UnitType':7},'Direction':{'Degrees':79,'Localized':'E','English':'E'}},'WindGust':{'Speed':{'Value':16.7,'Unit':'km/h','UnitType':7},'Direction':{'Degrees':15,'Localized':'NNE','English':'NNE'}},'TotalLiquid':{'Value':0.0,'Unit':'mm','UnitType':3},'Rain':{'Value':0.0,'Unit':'mm','UnitType':3},'Snow':{'Value':0.0,'Unit':'cm','UnitType':4},'Ice':{'Value':0.0,'Unit':'mm','UnitType':3},'HoursOfPrecipitation':0.0,'HoursOfRain':0.0,'HoursOfSnow':0.0,'HoursOfIce':0.0,'CloudCover':16},'Sources':['AccuWeather'],'MobileLink':'http://m.accuweather.com/en/ae/al-mateena/323066/daily-weather-forecast/323066?day=3&unit=c&lang=en-us','Link':'http://www.accuweather.com/en/ae/al-mateena/323066/daily-weather-forecast/323066?day=3&unit=c&lang=en-us'},{'Date':'2019-05-18T07:00:00+04:00','EpochDate':1558148400,'Sun':{'Rise':'2019-05-18T05:33:00+04:00','EpochRise':1558143180,'Set':'2019-05-18T18:58:00+04:00','EpochSet':1558191480},'Moon':{'Rise':'2019-05-18T18:34:00+04:00','EpochRise':1558190040,'Set':'2019-05-19T05:56:00+04:00','EpochSet':1558230960,'Phase':'Full','Age':14},'Temperature':{'Minimum':{'Value':28.7,'Unit':'C','UnitType':17},'Maximum':{'Value':38.2,'Unit':'C','UnitType':17}},'RealFeelTemperature':{'Minimum':{'Value':28.3,'Unit':'C','UnitType':17},'Maximum':{'Value':40.8,'Unit':'C','UnitType':17}},'RealFeelTemperatureShade':{'Minimum':{'Value':28.3,'Unit':'C','UnitType':17},'Maximum':{'Value':36.7,'Unit':'C','UnitType':17}},'HoursOfSun':6.0,'DegreeDaySummary':{'Heating':{'Value':0.0,'Unit':'C','UnitType':17},'Cooling':{'Value':15.0,'Unit':'C','UnitType':17}},'AirAndPollen':[{'Name':'AirQuality','Value':0,'Category':'Good','CategoryValue':1,'Type':'Ozone'},{'Name':'Grass','Value':0,'Category':'Low','CategoryValue':1},{'Name':'Mold','Value':0,'Category':'Low','CategoryValue':1},{'Name':'Ragweed','Value':0,'Category':'Low','CategoryValue':1},{'Name':'Tree','Value':0,'Category':'Low','CategoryValue':1},{'Name':'UVIndex','Value':12,'Category':'Extreme','CategoryValue':5}],'Day':{'Icon':4,'IconPhrase':'Intermittent clouds','ShortPhrase':'Clouds and sun; very warm','LongPhrase':'Times of sun and clouds; very warm','PrecipitationProbability':0,'ThunderstormProbability':0,'RainProbability':0,'SnowProbability':0,'IceProbability':0,'Wind':{'Speed':{'Value':14.8,'Unit':'km/h','UnitType':7},'Direction':{'Degrees':8,'Localized':'N','English':'N'}},'WindGust':{'Speed':{'Value':25.9,'Unit':'km/h','UnitType':7},'Direction':{'Degrees':331,'Localized':'NNW','English':'NNW'}},'TotalLiquid':{'Value':0.0,'Unit':'mm','UnitType':3},'Rain':{'Value':0.0,'Unit':'mm','UnitType':3},'Snow':{'Value':0.0,'Unit':'cm','UnitType':4},'Ice':{'Value':0.0,'Unit':'mm','UnitType':3},'HoursOfPrecipitation':0.0,'HoursOfRain':0.0,'HoursOfSnow':0.0,'HoursOfIce':0.0,'CloudCover':65},'Night':{'Icon':35,'IconPhrase':'Partly cloudy','ShortPhrase':'Partly cloudy; very warm','LongPhrase':'Partly cloudy; very warm','PrecipitationProbability':0,'ThunderstormProbability':0,'RainProbability':0,'SnowProbability':0,'IceProbability':0,'Wind':{'Speed':{'Value':7.4,'Unit':'km/h','UnitType':7},'Direction':{'Degrees':215,'Localized':'SW','English':'SW'}},'WindGust':{'Speed':{'Value':20.4,'Unit':'km/h','UnitType':7},'Direction':{'Degrees':316,'Localized':'NW','English':'NW'}},'TotalLiquid':{'Value':0.0,'Unit':'mm','UnitType':3},'Rain':{'Value':0.0,'Unit':'mm','UnitType':3},'Snow':{'Value':0.0,'Unit':'cm','UnitType':4},'Ice':{'Value':0.0,'Unit':'mm','UnitType':3},'HoursOfPrecipitation':0.0,'HoursOfRain':0.0,'HoursOfSnow':0.0,'HoursOfIce':0.0,'CloudCover':77},'Sources':['AccuWeather'],'MobileLink':'http://m.accuweather.com/en/ae/al-mateena/323066/daily-weather-forecast/323066?day=4&unit=c&lang=en-us','Link':'http://www.accuweather.com/en/ae/al-mateena/323066/daily-weather-forecast/323066?day=4&unit=c&lang=en-us'},{'Date':'2019-05-19T07:00:00+04:00','EpochDate':1558234800,'Sun':{'Rise':'2019-05-19T05:32:00+04:00','EpochRise':1558229520,'Set':'2019-05-19T18:58:00+04:00','EpochSet':1558277880},'Moon':{'Rise':'2019-05-19T19:35:00+04:00','EpochRise':1558280100,'Set':'2019-05-20T06:42:00+04:00','EpochSet':1558320120,'Phase':'WaningGibbous','Age':15},'Temperature':{'Minimum':{'Value':29.0,'Unit':'C','UnitType':17},'Maximum':{'Value':38.0,'Unit':'C','UnitType':17}},'RealFeelTemperature':{'Minimum':{'Value':29.0,'Unit':'C','UnitType':17},'Maximum':{'Value':41.0,'Unit':'C','UnitType':17}},'RealFeelTemperatureShade':{'Minimum':{'Value':29.0,'Unit':'C','UnitType':17},'Maximum':{'Value':36.6,'Unit':'C','UnitType':17}},'HoursOfSun':7.0,'DegreeDaySummary':{'Heating':{'Value':0.0,'Unit':'C','UnitType':17},'Cooling':{'Value':15.0,'Unit':'C','UnitType':17}},'AirAndPollen':[{'Name':'AirQuality','Value':0,'Category':'Good','CategoryValue':1,'Type':'Ozone'},{'Name':'Grass','Value':0,'Category':'Low','CategoryValue':1},{'Name':'Mold','Value':0,'Category':'Low','CategoryValue':1},{'Name':'Ragweed','Value':0,'Category':'Low','CategoryValue':1},{'Name':'Tree','Value':0,'Category':'Low','CategoryValue':1},{'Name':'UVIndex','Value':12,'Category':'Extreme','CategoryValue':5}],'Day':{'Icon':4,'IconPhrase':'Intermittent clouds','ShortPhrase':'Clouds and sun; very warm','LongPhrase':'A blend of sun and clouds; very warm','PrecipitationProbability':0,'ThunderstormProbability':0,'RainProbability':0,'SnowProbability':0,'IceProbability':0,'Wind':{'Speed':{'Value':13.0,'Unit':'km/h','UnitType':7},'Direction':{'Degrees':285,'Localized':'WNW','English':'WNW'}},'WindGust':{'Speed':{'Value':25.9,'Unit':'km/h','UnitType':7},'Direction':{'Degrees':329,'Localized':'NNW','English':'NNW'}},'TotalLiquid':{'Value':0.0,'Unit':'mm','UnitType':3},'Rain':{'Value':0.0,'Unit':'mm','UnitType':3},'Snow':{'Value':0.0,'Unit':'cm','UnitType':4},'Ice':{'Value':0.0,'Unit':'mm','UnitType':3},'HoursOfPrecipitation':0.0,'HoursOfRain':0.0,'HoursOfSnow':0.0,'HoursOfIce':0.0,'CloudCover':59},'Night':{'Icon':35,'IconPhrase':'Partly cloudy','ShortPhrase':'Partly cloudy; very warm','LongPhrase':'Partly cloudy; very warm','PrecipitationProbability':1,'ThunderstormProbability':0,'RainProbability':1,'SnowProbability':0,'IceProbability':0,'Wind':{'Speed':{'Value':9.3,'Unit':'km/h','UnitType':7},'Direction':{'Degrees':25,'Localized':'NNE','English':'NNE'}},'WindGust':{'Speed':{'Value':20.4,'Unit':'km/h','UnitType':7},'Direction':{'Degrees':333,'Localized':'NNW','English':'NNW'}},'TotalLiquid':{'Value':0.0,'Unit':'mm','UnitType':3},'Rain':{'Value':0.0,'Unit':'mm','UnitType':3},'Snow':{'Value':0.0,'Unit':'cm','UnitType':4},'Ice':{'Value':0.0,'Unit':'mm','UnitType':3},'HoursOfPrecipitation':0.0,'HoursOfRain':0.0,'HoursOfSnow':0.0,'HoursOfIce':0.0,'CloudCover':56},'Sources':['AccuWeather'],'MobileLink':'http://m.accuweather.com/en/ae/al-mateena/323066/daily-weather-forecast/323066?day=5&unit=c&lang=en-us','Link':'http://www.accuweather.com/en/ae/al-mateena/323066/daily-weather-forecast/323066?day=5&unit=c&lang=en-us'}]}]";
                var result = JsonConvert.DeserializeObject<List<Rootobject5>>(json);
                ObservableCollection<Rootobject5> trends = new ObservableCollection<Rootobject5>(result);
    
    
    
    
            }
    
    
        }
    
        public class Rootobject5
        {
            public Headline Headline { get; set; }
            public Dailyforecast[] DailyForecasts { get; set; }
        }
    
        public class Headline
        {
            public DateTime EffectiveDate { get; set; }
            public int EffectiveEpochDate { get; set; }
            public int Severity { get; set; }
            public string Text { get; set; }
            public string Category { get; set; }
            public DateTime EndDate { get; set; }
            public int EndEpochDate { get; set; }
            public string MobileLink { get; set; }
            public string Link { get; set; }
        }
    
        public class Dailyforecast
        {
            public DateTime Date { get; set; }
            public int EpochDate { get; set; }
            public Sun Sun { get; set; }
            public Moon Moon { get; set; }
            public Temperature Temperature { get; set; }
            public Realfeeltemperature RealFeelTemperature { get; set; }
            public Realfeeltemperatureshade RealFeelTemperatureShade { get; set; }
            public float HoursOfSun { get; set; }
            public Degreedaysummary DegreeDaySummary { get; set; }
            public Airandpollen[] AirAndPollen { get; set; }
            public Day Day { get; set; }
            public Night Night { get; set; }
            public string[] Sources { get; set; }
            public string MobileLink { get; set; }
            public string Link { get; set; }
        }
    
        public class Sun
        {
            public DateTime Rise { get; set; }
            public int EpochRise { get; set; }
            public DateTime Set { get; set; }
            public int EpochSet { get; set; }
        }
    
        public class Moon
        {
            public DateTime Rise { get; set; }
            public int EpochRise { get; set; }
            public DateTime Set { get; set; }
            public int EpochSet { get; set; }
            public string Phase { get; set; }
            public int Age { get; set; }
        }
    
        public class Temperature
        {
            public Minimum Minimum { get; set; }
            public Maximum Maximum { get; set; }
        }
    
        public class Minimum
        {
            public float Value { get; set; }
            public string Unit { get; set; }
            public int UnitType { get; set; }
        }
    
        public class Maximum
        {
            public float Value { get; set; }
            public string Unit { get; set; }
            public int UnitType { get; set; }
        }
    
        public class Realfeeltemperature
        {
            public Minimum1 Minimum { get; set; }
            public Maximum1 Maximum { get; set; }
        }
    
        public class Minimum1
        {
            public float Value { get; set; }
            public string Unit { get; set; }
            public int UnitType { get; set; }
        }
    
        public class Maximum1
        {
            public float Value { get; set; }
            public string Unit { get; set; }
            public int UnitType { get; set; }
        }
    
        public class Realfeeltemperatureshade
        {
            public Minimum2 Minimum { get; set; }
            public Maximum2 Maximum { get; set; }
        }
    
        public class Minimum2
        {
            public float Value { get; set; }
            public string Unit { get; set; }
            public int UnitType { get; set; }
        }
    
        public class Maximum2
        {
            public float Value { get; set; }
            public string Unit { get; set; }
            public int UnitType { get; set; }
        }
    
        public class Degreedaysummary
        {
            public Heating Heating { get; set; }
            public Cooling Cooling { get; set; }
        }
    
        public class Heating
        {
            public float Value { get; set; }
            public string Unit { get; set; }
            public int UnitType { get; set; }
        }
    
        public class Cooling
        {
            public float Value { get; set; }
            public string Unit { get; set; }
            public int UnitType { get; set; }
        }
    
        public class Day
        {
            public int Icon { get; set; }
            public string IconPhrase { get; set; }
            public string ShortPhrase { get; set; }
            public string LongPhrase { get; set; }
            public int PrecipitationProbability { get; set; }
            public int ThunderstormProbability { get; set; }
            public int RainProbability { get; set; }
            public int SnowProbability { get; set; }
            public int IceProbability { get; set; }
            public Wind Wind { get; set; }
            public Windgust WindGust { get; set; }
            public Totalliquid TotalLiquid { get; set; }
            public Rain Rain { get; set; }
            public Snow Snow { get; set; }
            public Ice Ice { get; set; }
            public float HoursOfPrecipitation { get; set; }
            public float HoursOfRain { get; set; }
            public float HoursOfSnow { get; set; }
            public float HoursOfIce { get; set; }
            public int CloudCover { get; set; }
        }
    
        public class Wind
        {
            public Speed Speed { get; set; }
            public Direction Direction { get; set; }
        }
    
        public class Speed
        {
            public float Value { get; set; }
            public string Unit { get; set; }
            public int UnitType { get; set; }
        }
    
        public class Direction
        {
            public int Degrees { get; set; }
            public string Localized { get; set; }
            public string English { get; set; }
        }
    
        public class Windgust
        {
            public Speed1 Speed { get; set; }
            public Direction1 Direction { get; set; }
        }
    
        public class Speed1
        {
            public float Value { get; set; }
            public string Unit { get; set; }
            public int UnitType { get; set; }
        }
    
        public class Direction1
        {
            public int Degrees { get; set; }
            public string Localized { get; set; }
            public string English { get; set; }
        }
    
        public class Totalliquid
        {
            public float Value { get; set; }
            public string Unit { get; set; }
            public int UnitType { get; set; }
        }
    
        public class Rain
        {
            public float Value { get; set; }
            public string Unit { get; set; }
            public int UnitType { get; set; }
        }
    
        public class Snow
        {
            public float Value { get; set; }
            public string Unit { get; set; }
            public int UnitType { get; set; }
        }
    
        public class Ice
        {
            public float Value { get; set; }
            public string Unit { get; set; }
            public int UnitType { get; set; }
        }
    
        public class Night
        {
            public int Icon { get; set; }
            public string IconPhrase { get; set; }
            public string ShortPhrase { get; set; }
            public string LongPhrase { get; set; }
            public int PrecipitationProbability { get; set; }
            public int ThunderstormProbability { get; set; }
            public int RainProbability { get; set; }
            public int SnowProbability { get; set; }
            public int IceProbability { get; set; }
            public Wind1 Wind { get; set; }
            public Windgust1 WindGust { get; set; }
            public Totalliquid1 TotalLiquid { get; set; }
            public Rain1 Rain { get; set; }
            public Snow1 Snow { get; set; }
            public Ice1 Ice { get; set; }
            public float HoursOfPrecipitation { get; set; }
            public float HoursOfRain { get; set; }
            public float HoursOfSnow { get; set; }
            public float HoursOfIce { get; set; }
            public int CloudCover { get; set; }
        }
    
        public class Wind1
        {
            public Speed2 Speed { get; set; }
            public Direction2 Direction { get; set; }
        }
    
        public class Speed2
        {
            public float Value { get; set; }
            public string Unit { get; set; }
            public int UnitType { get; set; }
        }
    
        public class Direction2
        {
            public int Degrees { get; set; }
            public string Localized { get; set; }
            public string English { get; set; }
        }
    
        public class Windgust1
        {
            public Speed3 Speed { get; set; }
            public Direction3 Direction { get; set; }
        }
    
        public class Speed3
        {
            public float Value { get; set; }
            public string Unit { get; set; }
            public int UnitType { get; set; }
        }
    
        public class Direction3
        {
            public int Degrees { get; set; }
            public string Localized { get; set; }
            public string English { get; set; }
        }
    
        public class Totalliquid1
        {
            public float Value { get; set; }
            public string Unit { get; set; }
            public int UnitType { get; set; }
        }
    
        public class Rain1
        {
            public float Value { get; set; }
            public string Unit { get; set; }
            public int UnitType { get; set; }
        }
    
        public class Snow1
        {
            public float Value { get; set; }
            public string Unit { get; set; }
            public int UnitType { get; set; }
        }
    
        public class Ice1
        {
            public float Value { get; set; }
            public string Unit { get; set; }
            public int UnitType { get; set; }
        }
    
        public class Airandpollen
        {
            public string Name { get; set; }
            public int Value { get; set; }
            public string Category { get; set; }
            public int CategoryValue { get; set; }
            public string Type { get; set; }
        }
    
    }

    Please note the "[]" at the beginning and end of the json data.

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Wednesday, May 15, 2019 6:05 AM
    Moderator