title: Json Deserialize Array C#
body: <p>I'm trying use json to get weather information from climatempo api, but I'm getting this error bellow, because one of the items is an array, I've tryed to change from:   </p>
  
  <pre><code>public static ClimaTempo15 FromJson(string json) =&gt; JsonConvert.DeserializeObject&lt;ClimaTempo15&gt;(json, NewWeatherImage15.Converter.Settings);
  </code></pre>
  
  <p>To </p>
  
  <pre><code>   public static List&lt;ClimaTempo15&gt; FromJson(string json) =&gt; JsonConvert.DeserializeObject&lt;List&lt;ClimaTempo15&gt;&gt;(json, NewWeatherImage15.Converter.Settings);
  </code></pre>
  
  <p>but I'm still geting the same error</p>
  
  <p>The Json is here <a href="https://pastebin.com/pfYzihSM" rel="nofollow noreferrer">https://pastebin.com/pfYzihSM</a></p>
  
  <blockquote>
    <p>Message=Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.List`1[NewWeatherImage15.Datum]' 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) 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.</p>
  </blockquote>
  
  <pre><code>namespace NewWeatherImage15
  {
      using System;
      using System.Collections.Generic;
  
      using System.Globalization;
      using Newtonsoft.Json;
      using Newtonsoft.Json.Converters;
  
      public partial class ClimaTempo15
      {
          [JsonProperty("id")]
          public long Id { get; set; }
  
          [JsonProperty("name")]
          public string Name { get; set; }
  
          [JsonProperty("state")]
          public string State { get; set; }
  
          [JsonProperty("country")]
          public string Country { get; set; }
  
          [JsonProperty("meteogram")]
          public Uri Meteogram { get; set; }
  
          [JsonProperty("data")]
          public List&lt;Datum&gt; Data { get; set; }
      }
  
      public partial class Datum
      {
          [JsonProperty("date")]
          public DateTimeOffset Date { get; set; }
  
          [JsonProperty("date_br")]
          public string DateBr { get; set; }
  
          [JsonProperty("humidity")]
          public Humidity Humidity { get; set; }
  
          [JsonProperty("rain")]
          public Rain Rain { get; set; }
  
          [JsonProperty("wind")]
          public Wind Wind { get; set; }
  
          [JsonProperty("thermal_sensation")]
          public ThermalSensation ThermalSensation { get; set; }
  
          [JsonProperty("text_icon")]
          public TextIcon TextIcon { get; set; }
  
          [JsonProperty("temperature")]
          public Humidity Temperature { get; set; }
  
          [JsonProperty("cloud_coverage")]
          public CloudCoverage CloudCoverage { get; set; }
  
          [JsonProperty("sun")]
          public Sun Sun { get; set; }
      }
  
      public partial class CloudCoverage
      {
          [JsonProperty("low")]
          public long Low { get; set; }
  
          [JsonProperty("mid")]
          public long Mid { get; set; }
  
          [JsonProperty("high")]
          public long High { get; set; }
  
          [JsonProperty("dawn")]
          public CloudCoverageAfternoon Dawn { get; set; }
  
          [JsonProperty("morning")]
          public CloudCoverageAfternoon Morning { get; set; }
  
          [JsonProperty("afternoon")]
          public CloudCoverageAfternoon Afternoon { get; set; }
  
          [JsonProperty("night")]
          public CloudCoverageAfternoon Night { get; set; }
      }
  
      public partial class CloudCoverageAfternoon
      {
          [JsonProperty("low")]
          public long Low { get; set; }
  
          [JsonProperty("mid")]
          public long Mid { get; set; }
  
          [JsonProperty("high")]
          public long High { get; set; }
      }
  
      public partial class Humidity
      {
          [JsonProperty("min")]
          public long Min { get; set; }
  
          [JsonProperty("max")]
          public long Max { get; set; }
  
          [JsonProperty("dawn")]
          public ThermalSensation Dawn { get; set; }
  
          [JsonProperty("morning")]
          public ThermalSensation Morning { get; set; }
  
          [JsonProperty("afternoon")]
          public ThermalSensation Afternoon { get; set; }
  
          [JsonProperty("night")]
          public ThermalSensation Night { get; set; }
      }
  
      public partial class ThermalSensation
      {
          [JsonProperty("min")]
          public long Min { get; set; }
  
          [JsonProperty("max")]
          public long Max { get; set; }
      }
  
      public partial class Rain
      {
          [JsonProperty("probability")]
          public long Probability { get; set; }
  
          [JsonProperty("precipitation")]
          public long Precipitation { get; set; }
      }
  
      public partial class Sun
      {
          [JsonProperty("sunrise")]
          public DateTimeOffset Sunrise { get; set; }
  
          [JsonProperty("sunset")]
          public DateTimeOffset Sunset { get; set; }
      }
  
      public partial class TextIcon
      {
          [JsonProperty("icon")]
          public Icon Icon { get; set; }
  
          [JsonProperty("text")]
          public Text Text { get; set; }
      }
  
      public partial class Icon
      {
          [JsonProperty("dawn")]
          public string Dawn { get; set; }
  
          [JsonProperty("morning")]
          public string Morning { get; set; }
  
          [JsonProperty("afternoon")]
          public string Afternoon { get; set; }
  
          [JsonProperty("night")]
          public string Night { get; set; }
  
          [JsonProperty("day", NullValueHandling = NullValueHandling.Ignore)]
          [JsonConverter(typeof(ParseStringConverter))]
          public long? Day { get; set; }
  
          [JsonProperty("reduced", NullValueHandling = NullValueHandling.Ignore)]
          public string Reduced { get; set; }
      }
  
      public partial class Text
      {
          [JsonProperty("pt")]
          public string Pt { get; set; }
  
          [JsonProperty("en")]
          public string En { get; set; }
  
          [JsonProperty("es")]
          public string Es { get; set; }
  
          [JsonProperty("phrase")]
          public Icon Phrase { get; set; }
      }
  
      public partial class Wind
      {
          [JsonProperty("velocity_min")]
          public long VelocityMin { get; set; }
  
          [JsonProperty("velocity_max")]
          public long VelocityMax { get; set; }
  
          [JsonProperty("velocity_avg")]
          public long VelocityAvg { get; set; }
  
          [JsonProperty("gust_max")]
          public long GustMax { get; set; }
  
          [JsonProperty("direction_degrees")]
          public long DirectionDegrees { get; set; }
  
          [JsonProperty("direction")]
          public string Direction { get; set; }
  
          [JsonProperty("dawn")]
          public WindAfternoon Dawn { get; set; }
  
          [JsonProperty("morning")]
          public WindAfternoon Morning { get; set; }
  
          [JsonProperty("afternoon")]
          public WindAfternoon Afternoon { get; set; }
  
          [JsonProperty("night")]
          public WindAfternoon Night { get; set; }
      }
  
      public partial class WindAfternoon
      {
          [JsonProperty("direction")]
          public string Direction { get; set; }
  
          [JsonProperty("direction_degrees")]
          public long DirectionDegrees { get; set; }
  
          [JsonProperty("gust_max")]
          public long GustMax { get; set; }
  
          [JsonProperty("velocity_max")]
          public long VelocityMax { get; set; }
  
          [JsonProperty("velocity_avg")]
          public long VelocityAvg { get; set; }
      }
  
      public partial class ClimaTempo15
      {
            public static ClimaTempo15 FromJson(string json) =&gt; JsonConvert.DeserializeObject&lt;ClimaTempo15&gt;(json, NewWeatherImage15.Converter.Settings);
         // public static List&lt;ClimaTempo15&gt; FromJson(string json) =&gt; JsonConvert.DeserializeObject&lt;List&lt;ClimaTempo15&gt;&gt;(json, NewWeatherImage15.Converter.Settings);
      }
  
      public static class Serialize
      {
          public static string ToJson(this ClimaTempo15 self) =&gt; JsonConvert.SerializeObject(self, NewWeatherImage15.Converter.Settings);
      }
  
      internal static class Converter
      {
          public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings
          {
              MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
              DateParseHandling = DateParseHandling.None,
              Converters =
              {
                  new IsoDateTimeConverter { DateTimeStyles = DateTimeStyles.AssumeUniversal }
              },
          };
      }
  
      internal class ParseStringConverter : JsonConverter
      {
          public override bool CanConvert(Type t) =&gt; t == typeof(long) || t == typeof(long?);
  
          public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
          {
              if (reader.TokenType == JsonToken.Null) return null;
              var value = serializer.Deserialize&lt;string&gt;(reader);
              long l;
              if (Int64.TryParse(value, out l))
              {
                  return l;
              }
              throw new Exception("Cannot unmarshal type long");
          }
  
          public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
          {
              if (untypedValue == null)
              {
                  serializer.Serialize(writer, null);
                  return;
              }
              var value = (long)untypedValue;
              serializer.Serialize(writer, value.ToString());
              return;
          }
  
          public static readonly ParseStringConverter Singleton = new ParseStringConverter();
      }
  }
  </code></pre>