Q:

C# Json Deserialization fails

I'm trying to make an application that can show local TV guide trough JSON rest api C #, but has some problems with deserialization of my Json response.
i'm only intresest in the array NOW in my json call and i do not own the api service.
I get this error message:

An exception of type 'Newtonsoft.Json.JsonSerializationException' occurred in Newtonsoft.Json.DLL but was not handled in user code
Additional information: Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.List`1[TDC_Play_TV_Mobil.superclass2+Now]' 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.
Path 'now', line 1, position 7.

My function:
private HttpClient client;

   public async Task<List<superclass2.Now>> GetComments()
   {
       client = new HttpClient();
      var response = await client.GetAsync(new Uri("http://api.yousee.tv/rest/tvguide/nowandnext/"));
       if (response.IsSuccessStatusCode)
       {
           
           string json = await response.Content.ReadAsStringAsync();

           System.Diagnostics.Debug.WriteLine(json);
           var task = Task.Factory.StartNew(() => JsonConvert.DeserializeObject<List<superclass2.Now>>(json));

           var value = await task;
         //  List<superclass2.Now> comments = Newtonsoft.Json.JsonConvert.DeserializeObject<List<superclass2.Now>>(await json);
          System.Diagnostics.Debug.WriteLine("Comments er lavet");
          return value;

       }
       else
       {
           throw new Exception("Errorhandling message");

       }
        

   }

My class file:
public class superclass2
{
public class Logos
   {
       public string small { get; set; }
       public string large { get; set; }
       public string small_seapp { get; set; }
       public string large_seapp { get; set; }
       public string extralarge { get; set; }
       public string super { get; set; }
       public string mega { get; set; }
       public string netgem { get; set; }
       public string svg { get; set; }
   }

   public class ChannelInfo
   {
       public string name { get; set; }
       public string shortname { get; set; }
       public string logo_image_prefix { get; set; }
       public Logos logos { get; set; }
       public int archivedays { get; set; }
       public string channelcolor { get; set; }
   }

   public class FormattedDate
   {
       public string time_begin { get; set; }
       public string time_end { get; set; }
       public string date { get; set; }
   }

   public class ImagesSixteenbynine
   {
       public string large { get; set; }
       public string medium { get; set; }
       public string small { get; set; }
   }

   public class ImagesFourbythree
   {
       public string large { get; set; }
       public string small { get; set; }
   }

   public class ImagesSquare
   {
       public string large { get; set; }
       public string medium { get; set; }
       public string small { get; set; }
   }

   public class Now
   {
       public int id { get; set; }
       public int dvb_id { get; set; }
       public int channel { get; set; }
       public ChannelInfo channel_info { get; set; }
       public string orgtitle { get; set; }
       public string cast { get; set; }
       public string directors { get; set; }
       public string series_info { get; set; }
       public int series_id { get; set; }
       public string series_name { get; set; }
       public bool allowseriesrecording { get; set; }
       public int totalinarchive { get; set; }
       public int popularity_score { get; set; }
       public int totalupcoming { get; set; }
       public int category { get; set; }
       public int subcategory { get; set; }
       public string category_string { get; set; }
       public string subcategory_string { get; set; }
       public int begin { get; set; }
       public object actual_begin { get; set; }
       public int end { get; set; }
       public int actual_end { get; set; }
       public int tvdate { get; set; }
       public FormattedDate formatted_date { get; set; }
       public string title { get; set; }
       public string description { get; set; }
       public bool archive { get; set; }
       public bool scrubbingallowed { get; set; }
       public int expiresfromarchive { get; set; }
       public bool startover { get; set; }
       public string imageprefix { get; set; }
       public ImagesSixteenbynine images_sixteenbynine { get; set; }
       public ImagesFourbythree images_fourbythree { get; set; }
       public ImagesSquare images_square { get; set; }
       public List<object> decorations { get; set; }
   }

   public class Logos2
   {
       public string small { get; set; }
       public string large { get; set; }
       public string small_seapp { get; set; }
       public string large_seapp { get; set; }
       public string extralarge { get; set; }
       public string super { get; set; }
       public string mega { get; set; }
       public string netgem { get; set; }
       public string svg { get; set; }
   }

   public class ChannelInfo2
   {
       public string name { get; set; }
       public string shortname { get; set; }
       public string logo_image_prefix { get; set; }
       public Logos2 logos { get; set; }
       public int archivedays { get; set; }
       public string channelcolor { get; set; }
   }

   public class FormattedDate2
   {
       public string time_begin { get; set; }
       public string time_end { get; set; }
       public string date { get; set; }
   }

   public class ImagesSixteenbynine2
   {
       public string large { get; set; }
       public string medium { get; set; }
       public string small { get; set; }
   }

   public class ImagesFourbythree2
   {
       public string large { get; set; }
       public string small { get; set; }
   }

   public class ImagesSquare2
   {
       public string large { get; set; }
       public string medium { get; set; }
       public string small { get; set; }
   }

   public class Next
   {
       public int id { get; set; }
       public int dvb_id { get; set; }
       public int channel { get; set; }
       public ChannelInfo2 channel_info { get; set; }
       public string orgtitle { get; set; }
       public string cast { get; set; }
       public string directors { get; set; }
       public string series_info { get; set; }
       public int series_id { get; set; }
       public string series_name { get; set; }
       public bool allowseriesrecording { get; set; }
       public int totalinarchive { get; set; }
       public int popularity_score { get; set; }
       public int totalupcoming { get; set; }
       public int category { get; set; }
       public int subcategory { get; set; }
       public string category_string { get; set; }
       public string subcategory_string { get; set; }
       public int begin { get; set; }
       public int actual_begin { get; set; }
       public int end { get; set; }
       public int actual_end { get; set; }
       public int tvdate { get; set; }
       public FormattedDate2 formatted_date { get; set; }
       public string title { get; set; }
       public string description { get; set; }
       public bool archive { get; set; }
       public bool scrubbingallowed { get; set; }
       public int expiresfromarchive { get; set; }
       public bool startover { get; set; }
       public string imageprefix { get; set; }
       public ImagesSixteenbynine2 images_sixteenbynine { get; set; }
       public ImagesFourbythree2 images_fourbythree { get; set; }
       public ImagesSquare2 images_square { get; set; }
       public List<object> decorations { get; set; }
   }

   public class RootObject
   {
       public List<Now> now { get; set; }
       public List<Next> next { get; set; }
   }

}

A:

Your JSON isn't a List<superclass2.Now>, it's a superclass2.RootObject.  So you need to do something like:
    public async Task<List<superclass2.Now>> GetComments()    
    {
        client = new HttpClient();
        var response = await client.GetAsync(new Uri("http://api.yousee.tv/rest/tvguide/nowandnext/"));
        if (response.IsSuccessStatusCode)
        {
            string json = await response.Content.ReadAsStringAsync();
            System.Diagnostics.Debug.WriteLine(json);
            var task = Task.Factory.StartNew(() => JsonConvert.DeserializeObject<superclass2.RootObject>(json));

            var value = await task;
            System.Diagnostics.Debug.WriteLine("Comments er lavet");
            return (value == null ? null : value.now);
        }
        else
        {
            throw new Exception("Errorhandling message");
        }
    }

Agree with Jon Skeet it would be nicer to eliminate the nesting of classes, purely for improved readability.  If you need these classes to exist only in a specific scope, it is better to use nested namespaces.  They aren't causing your bug, however.

