title: Deserialize JSON Stream with JSON.net
body: <p>I recently switched from using SOAP to JSON. I now have a problem with the performance because it takes about 26 seconds to deserialize the JSON stream on my WP7 device.</p>
  
  <p>Therefore I thought about using Json.net instead of DataContractJsonSerializer.</p>
  
  <p>However, I was not able to find much information about this.</p>
  
  <p>I use a webclient and then OpenReadAsync, so I have a Stream as e.Result.</p>
  
  <p>How can I turn that stream into an object using Json.net?</p>
  
  <p>Should I maybe use DownloadStringAsync instead?</p>
  
  <p>This is the Code that currently works:</p>
  
  <pre><code>//string URL = ""; //Actual URL to JSON is here
  
  WebClient client = new WebClient();
  client.OpenReadCompleted += new OpenReadCompletedEventHandler(client_OpenReadCompleted);
  client.OpenReadAsync(new Uri(URL, UriKind.Absolute));
  </code></pre>
  
  <p>And the event handler:</p>
  
  <pre><code>void client_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
  {
       DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(JSONObject), null);
       JSONObject data = serializer.ReadObject(e.Result) as JSONObject;
  }
  </code></pre>
  
  <p>JSONObject is the response object of the service's SOAP endpoint, but both endpoints return the same data.</p>
  
  <p>This works fine and I can go on and parse data just like I parsed the SOAP response, but I would like it do deserialize faster.</p>