title: Using JSON.NET converter to deserialize Dictionary with interface value
body: <p>Given these class definitions:</p>
  
  <pre><code>public class TypeConverter&lt;T&gt; : JsonConverter
  {
      public override bool CanConvert(Type objectType) =&gt; true;
  
      public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) =&gt; serializer.Serialize(writer, value);
  
      public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) =&gt; serializer.Deserialize&lt;T&gt;(reader);
  }
  
  public interface ISubStuff
  {
      string Item { get; set; }
  }
  
  public class SubStuff : ISubStuff
  {
     public string Item { get; set; }
  }
  
  public interface IMainStuff
  {
      Dictionary&lt;string, ISubStuff&gt; SubStuff { get; set; }
  }
  </code></pre>
  
  <p>I am trying to use the TypeConverter class in method declaration for deserialization as below but it's NOT working:</p>
  
  <pre><code>public class MainStuff : IMainStuff
  { 
      [JsonConverter(typeof(TypeConverter&lt;Dictionary&lt;string, SubStuff&gt;&gt;))] 
      public Dictionary&lt;string, ISubStuff&gt; SubStuff
      { 
          get; 
          set; 
      } 
  }
  </code></pre>
  
  <p>The call below to deserialize the json causes an <code>unable to cast object of type Dictionary&lt;string, SubStuff&gt; to Dictionary&lt;string, ISubStuff&gt;</code> exception. </p>
  
  <pre><code>var jsonText = "{ \"SubStuff\": { } }"; 
  var deser = JsonConvert.DeserializeObject&lt;MainStuff&gt;&lt;jsonText);
  </code></pre>