title: converting from json to c# class object
body: <p>I try to convert from json to c# class object, cause my final step will be put this all data into local db. I have no problem with taking this data like one big string, so the Url is good typed, but it's not my goal.</p>
  
  <p>this is the json data, here we have two objects </p>
  
  <pre><code>[{"id":"1","category":"1","name":"good 1","prize":"12.3","prize2":"13.4","elements":"row,column,paper","secid":"2131","description":"nice","quality":"best","dateofcoming":"2013-12-20 18:08:50","date":"2013-12-20 00:00:00"},
  {"id":"2","category":"2","name":"good","prize":"14.3","prize2":"15.4","elements":"up,down,left","secid":"2132","description":"nc","quality":"best","dateofcoming":"2013-12-20 18:10:55","date":"2013-12-20 00:00:00"}]
  </code></pre>
  
  <p>I try by this way which I found in the book:</p>
  
  <pre><code>  private void getBookData()
      {
          // we creating the request details to the site which give us 
          // back the json data 
          HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("here is my adress");
         request.Accept = "and header";
          // starting the request
          request.BeginGetResponse(callback_with_food_info, request);
      }
  
      private void callback_with_food_info(IAsyncResult ar)
      {
  
          HttpWebRequest request = (HttpWebRequest)ar.AsyncState;
          // we get the response
          HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(ar);
  
          DataContractJsonSerializer deserializer = new DataContractJsonSerializer(typeof(ListOfObjects));
  
          Stream responseStream = response.GetResponseStream();
  
          ListOfObjects listOfobj = (ListOfObjects)deserializer.ReadObject(responseStream);
          String fsdfsdf = "how how how";
  
  
  
      }
  </code></pre>
  
  <p>and in the row when we ReadObject</p>
  
  <pre><code> ListOfObjects listOfobj = (ListOfObjects)deserializer.ReadObject(responseStream);
  </code></pre>
  
  <p>I get exception "System.InvalidCastException", my List class look like this and it was created by <a href="http://json2csharp.com/" rel="nofollow">http://json2csharp.com/</a></p>
  
  <pre><code>  public class DetailsOfObject
     {  
      public string id { get; set; }
      public string category { get; set; }
      public string name { get; set; }
      public string prize { get; set; }
      public string prize2 { get; set; }
      public string elements { get; set; }
      public string secid { get; set; }
      public string description { get; set; }
      public string quality { get; set; }
      public string dateofcoming { get; set; }
      public string date { get; set; }
  }
  
  public class ListOfObjects 
  {
      public DetailsOfObject list {get; set;}
  }
  </code></pre>
  
  <p>Any advice how to finally convert this json data</p>