title: Deserialize json result to dynamic object
body: <p>I want to deserialize json result returned from API call. For different API method calls, data will be in different class objects.</p>
  
  <p>I mean my ApiResponse class is: </p>
  
  <pre><code>public class ApiResponse
  {
      public object Data { get; set; }
      public string ResultCode { get; set; }
      public string ResultMessage { get; set; }
      public string Exception { get; set; }
  }
  </code></pre>
  
  <p>When Method1 for API is called. Data will be Method1Result object, when Method2 is called Data will be a Method2Result object</p>
  
  <pre><code>public class Method1Result
  {
      public int property1 { get; set; }
      public string property2 { get; set; }
  }
  
  public class Method2Result
  {
      public string property3 { get; set; }
      public decimal property4 { get; set; }
  }
  </code></pre>
  
  <p>Here are the json results from Method1 and Method2 calls:</p>
  
  <pre><code>{"Data": { “property1” : 1, “property2” : "test" }
  ,"ResultCode":"Success","ResultMessage":"","Exception":null}
  
  {"Data": { “property3” : "ok", “property4” : 10 }
  ,"ResultCode":"Success","ResultMessage":"","Exception":null}
  </code></pre>
  
  <p>There are two methods for these </p>
  
  <pre><code>private ApiResponse Method1Call(ApiRequest request)
      {
          JavaScriptSerializer serializer1 = new JavaScriptSerializer();
  
          string serviceAddress = "/Method1";
          var pResponseJson = HttpCall(serializer1.Serialize(request),serviceAddress);
  
          ApiResponse response = serializer1.Deserialize&lt;ApiResponse&gt;(pResponseJson);
  
          // I WANT TO GET PROPERTY OF property1 and property2 here
          int temp = ((Method1Result)response.Data).property1;
          return apiResponse;
      }
  
   private ApiResponse Method2Call(ApiRequest request)
      {
          JavaScriptSerializer serializer1 = new JavaScriptSerializer();
  
          string serviceAddress = "/Method2";
          var pResponseJson = HttpCall(serializer1.Serialize(request),serviceAddress);
  
          ApiResponse response = serializer1.Deserialize&lt;ApiResponse&gt;(pResponseJson);
  
          // I WANT TO GET PROPERTY OF property3 and property4 here
          string temp = ((Method2Result)response.Data).property3;
          return apiResponse;
      }
  </code></pre>
  
  <p>i want to deserialize Data object based on method calls. Could you please help me to do that ? </p>