title: Deserialize json with json.net c#
body: <p>am new to Json so a little green.</p>
  
  <p>I have a Rest Based Service that returns a json string;</p>
  
  <pre><code>{"treeNode":[{"id":"U-2905","pid":"R","userId":"2905"},
  {"id":"U-2905","pid":"R","userId":"2905"}]}
  </code></pre>
  
  <p>I have been playing with the Json.net and trying to Deserialize the string into Objects etc.
  I wrote an extention method to help.</p>
  
  <pre><code>public static T DeserializeFromJSON&lt;T&gt;(this Stream jsonStream, Type objectType)
          {
              T result;
  
              using (StreamReader reader = new StreamReader(jsonStream))
              {
                  JsonSerializer serializer = new JsonSerializer();
                  try
                  {
                      result = (T)serializer.Deserialize(reader, objectType);
                  }
                  catch (Exception e)
                  {   
                      throw;
                  }
  
              }
              return result;
          }
  </code></pre>
  
  <p>I was expecting an array of treeNode[] objects. But its seems that I can only deserialize correctly if treeNode[] property of another object.</p>
  
  <pre><code>public class treeNode
  {
      public string id { get; set; }
      public string pid { get; set; }
      public string userId { get; set; }
  }
  </code></pre>
  
  <p>I there a way to to just get an straight array from the deserialization ?</p>
  
  <p>Cheers</p>