title: Json.NET how to override serialization for a type that defines a custom JsonConverter via an attribute?
body: <p>I am trying to deserialize a class using Json.NET and a custom JsonConverter object. The class currently defines a converter for default serialization using the JsonConverterAttribute. I need to do a custom deserialization by passing in a custom converter. However, the deserialization still seems to be using the default converter. How can I get Json.NET to prefer my custom converter?</p>
  
  <p>Here's a bit of sample code that demonstrates the issue. I'm using NewtonSoft.Json 4.5.11:</p>
  
  <pre><code>void Main()
  {
      JsonConvert.DeserializeObject&lt;Foo&gt;("{}"); // throws "in the default converter"
      var settings = new JsonSerializerSettings { Converters = new[] { new CustomConverter() } };
      JsonConvert.DeserializeObject&lt;Foo&gt;("{}", settings); // still throws "in the default converter" :-/
  }
  
  [JsonConverter(typeof(DefaultConverter))]
  public class Foo {
  }
  
  public class DefaultConverter : JsonConverter {
      public override bool CanConvert(Type objectType)
      {
          return typeof(Foo).IsAssignableFrom(objectType);
      }
  
      public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
      {
          throw new Exception("in the default converter!");
      }
  
      public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
      {
          throw new Exception("in the default converter!");
      }
  }
  
  public class CustomConverter : JsonConverter {
      public override bool CanConvert(Type objectType)
      {
          return typeof(Foo).IsAssignableFrom(objectType);
      }
  
      public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
      {
          throw new Exception("in the custom converter!");
      }
  
      public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
      {
          throw new Exception("in the custom converter!");
      }
  }
  </code></pre>