title: How to use DataContractJsonSerializer to parse a nested json object?
body: <p>I have a json text like this:</p>
  
  <pre><code>{
      "response":200,
      "result":
    {
        "package":
      {
        "token":"aaa"
      }
    }
  }
  </code></pre>
  
  <p>I am using DataContractJsonSerializer to extract info from this above json.</p>
  
  <pre><code>public static T Deserialize&lt;T&gt;(string json)
  {
      var instance = Activator.CreateInstance&lt;T&gt;();
      using (var ms = new MemoryStream(Encoding.Unicode.GetBytes(json)))
      {
           var serializer = new DataContractJsonSerializer(instance.GetType());
           return (T)serializer.ReadObject(ms);
      }
  }
  </code></pre>
  
  <p>I describe the classes as follow:</p>
  
  <pre><code>[DataContract]
  class IttResponse
  {
      [DataMember(Name = "response")]
      public int Response { get; protected set; }
  
      [DataMember(Name = "result")]
      public string Result { get; protected set; }
  }
  
  [DataContract]
  public class IttPackage
  {
  
      [DataMember(Name = "token")]
      public string Token { get; set; }
  }
  </code></pre>
  
  <p>Now, I tried to parse the json text as follow:</p>
  
  <pre><code>IttResponse response = Deserialize&lt;IttResponse&gt;(jsonText);
  IttPackage package = Deserialize&lt;IttPackage&gt;(response.token);
  </code></pre>
  
  <p>However, I always get error when parsing jsonText at the first line.</p>
  
  <p>Note: I am developing an application running on desktop written in C#, VS Ultimate 2013, .Net Framework 4.5</p>
  
  <p>So, I think, I cannot use <strong>System.Web.Helpers</strong>, or <strong>System.Web.Script.Serialization</strong> to parse.</p>