title: Incremental JSON Parsing in C#
body: <p>I am trying to parse the JSON incrementally, i.e. based on a condition. </p>
  
  <p>Below is my json message and I am currently using JavaScriptSerializer to deserialize the message. </p>
  
  <pre><code>string json = @"{"id":2,
  "method":"add",
  "params":
     {"object":
         {"name":"test"
          "id":"1"},
          "position":"1"}
    }";
  
  JavaScriptSerializer js = new JavaScriptSerializer();
  Message m = js.Deserialize&lt;Message&gt;(json);
  </code></pre>
  
  <p>Message class is shown below:</p>
  
  <pre><code> public class Message
   {
          public string id { get; set; }
          public string method { get; set; }
          public Params @params { get; set; }
          public string position { get; set; }
   }
  public class Params
  {
          public string name { get; set; }
          public string id{ get; set; 
  }
  </code></pre>
  
  <p>The above code parses the message with no problems. But it parses the entire JSON at once. I want it to proceed parsing only if the "method" parameter's value is "add". If it is not "add", then I don't want it to proceed to parse rest of the message. Is there a way to do incremental parsing based on a condition in C#? (Environment: VS 2008 with .Net 3.5)</p>