title: Most efficient way to parse JSON in C#
body: <p>I was wondering what is the most efficient way to parse JSON in C#? And by efficient I mean the one with the lower response time. I am trying to parse a large amount of data using a couple of methods, and response time in both of these methods are high. Can anyone tell me the difference between the following methods? Is there an alternative that would let me parse with a lower response time?</p>
  
  <p>Option 1:</p>
  
  <pre><code>HttpWebRequest request = WebRequest.Create(jsonURL) as HttpWebRequest;
  using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
  {
      if (response.StatusCode != HttpStatusCode.OK)
          throw new Exception(String.Format(
          "Server error (HTTP {0}: {1}).",
          response.StatusCode,
          response.StatusDescription));
      DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(typeof(obj));
      object objResponse = jsonSerializer.ReadObject(response.GetResponseStream());
  }  
  </code></pre>
  
  <p>Option 2:</p>
  
  <pre><code>var json = new WebClient().DownloadString(jsonURL);
  using (MemoryStream ms = new MemoryStream(Encoding.Unicode.GetBytes(json)))
  {
      DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(typeof(obj));
      object objResponse = jsonSerializer.ReadObject(ms);
  }  
  </code></pre>