title: Deserialize problem with Customized DataType implementing IConvertible
body: <p>I have a class <code>ChargesDetail</code> and am trying to deserialize json as shown below. Here I have used datatype that is <code>Amount</code>.</p>
  
  <pre><code>public class ChargesDetail
  {
     public double DiscountRate { get; set; }
     public Amount DiscountAmount { get; set; }
  }
  
  public class Amount:IConvertible 
  {
      private double _val = 0;
      private int _decimal = 5;
  
      public Amount()
      {
      }
  
      public Amount(double amount): this()            
      {
         // this.Value = amount;
          _val = Math.Round(amount, _decimal);
      }
  
      #region IConvertible Members
  
      // Implementation snipped
  
      #endregion
  }
  </code></pre>
  
  <p>And my JSON looks like:</p>
  
  <pre><code>{ "DiscountRate":0.0, "DiscountAmount":0.0 }
  </code></pre>
  
  <p>Am trying to deserialize as like this:</p>
  
  <pre><code>T result = JsonConvert.DeserializeObject&lt;ChargesDetail&gt;(json);
  </code></pre>
  
  <p>It  is giving me an exception like: </p>
  
  <blockquote>
    <p>Invalid cast from 'System.Double'
    to 'Amount'.</p>
    
    <p>at System.Convert.DefaultToType(IConvertible value, Type
    targetType, IFormatProvider provider)    at
    System.Double.System.IConvertible.ToType(Type type, IFormatProvider
    provider)    at System.Convert.ChangeType(Object value, Type
    conversionType, IFormatProvider provider)    at
    Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader
    reader, Object value, CultureInfo culture, JsonContract contract, Type
    targetType)</p>
  </blockquote>
  
  <p>How to deserialize json to this customized datatype?</p>
  
  <ul>
  <li>I cannot remove IConvertible, bcz it throws System.StackOverflowException in some calculations.</li>
  <li>I cannot change Amount type to double type, bcz there are more than 100 properties of same type and doing calculations in 'Amount' class. </li>
  </ul>