title: Passing additional information to a JsonConverter
body: <p>I find myself doing this a lot. I have a class that looks something like this:</p>
  
  <pre><code>public class Foo
  {
      public SomeEnum SomeValue { get; set; }
      public SomeAbstractBaseClass SomeObject { get; set; }
  }
  </code></pre>
  
  <p>And what I need to do is deserialize a <em>specfic</em> class derived from <code>SomeAbstractBaseClass</code> based on the value in <code>SomeValue</code>. So what I do is put a <code>JsonConverterAttribute</code> on the whole class and then write a custom converter derived from <code>JsonConverter</code> that will in its <code>ReadJson</code>, first examine <code>SomeValue</code> and then have some logic to deserialize <code>SomeObject</code> to a specific class. This works, but it's kind of annoying. The only part that really needs special handling is the <code>SomeObject</code> property, but I have to put the converter at the higher level of the class and have my converter be responsible for populating all the other members of <code>Foo</code> (i.e. <code>SomeValue</code>, but you could imagine if you had lots of other properties that were fine with the default deserialization behavior). This could be avoided if there was only some way to get access to the parent object (or at least some property or properties from it) in the <code>ReadJson</code> method of <code>JsonConverter</code>. But there doesn't seem to be any way to do that. So if I could do something like:</p>
  
  <pre><code>public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
  {
      var parent = //...somehow access the parent or at least SomeValue
      switch (parent.SomeValue)
      {
          case Value1:
          serialized.Deserialize&lt;SpecificType1&gt;(reader);   
          break;
          //... other cases
      }
  }
  </code></pre>
  
  <p>There is the very suggestively named <code>existingValue</code> parameter, but it always seems to be null? Is there a better way to do this?</p>