title: How to conditionally deserialize JSON object based on another JSON property?
body: <p>Suppose I have following model class:</p>
  
  <pre><code>public class Action
  {
      public enum Type
      {
          Open,
          Close,
          Remove,
          Delete,
          Reverse,
          Alert,
          ScaleInOut,
          Nothing
      }
  
      [JsonProperty("id")]
      public string Id { get; set; }
  
      [JsonProperty("name")]
      public string Name { get; set; }
  
      [JsonProperty("active")]
      [JsonConverter(typeof(IntToBoolConverter))]
      public bool Active { get; set; }
  
      [JsonProperty("type")]
      [JsonConverter(typeof(ActionTypeConverter))]
      public Type ActionType { get; set; }
  
      [JsonProperty("result")]
      [JsonConverter(typeof(ActionResultConverter))]
      public ActionResult Result { get; set; }
  }
  </code></pre>
  
  <p>and I want to deserialize following JSON into that class:</p>
  
  <pre><code>{
      "name":"test1",
      "id":"aa0832f0508bb580ce7f0506132c1c13",
      "active":"1",
      "type":"open",
      "result":{
          "property1":"buy",
          "property2":"123.123",
          "property3":"2016-07-16T23:00:00",
          "property4":"768",
          "property5":true
       }
  }
  </code></pre>
  
  <p>Result object can be different each time (one of 6 models) and its type depends on JSON property <code>type</code>.</p>
  
  <p>I have created custom <code>ActionResultConverter</code> (<code>JsonConverter</code> annotation above <code>Result</code> property of <code>Action</code> class) that should be able to create <strong>specific</strong> <code>result</code> <strong>object</strong> based on string in <code>type</code> property of JSON.</p>
  
  <p>My problem is that I don't know how to access that property from converter because only the <code>result</code> part of whole JSON is passed to <code>JsonReader</code>.</p>
  
  <p>Any ideas or help will be appreciated.</p>
  
  <p>Thanks!</p>