title: Force constructor parameter value in Json.net deserialization
body: <p>Is it possible to force Json.net to pass a default value for a constructor parameter?</p>
  
  <p>I have tried using a custom <code>ContractResolver</code> that overrides the <code>CreateConstructorParameters</code> and <code>CreatePropertyFromConstructorParameter</code> methods and sets the returned <code>JsonProperty.DefaultValue</code> property to my desired value and <code>DefaultValueHandling</code> property to <code>DefaultValueHandling.Populate</code>. </p>
  
  <p>By overriding the <code>CreateObjectContract</code> method, I can see that the matching <code>CreatorParameters</code> and <code>Properties</code> both include my default value. However, I am still getting a <code>null</code> value passed to the constructors.</p>
  
  <p>I have even tried setting the <code>Converter</code> on the properties to a converter that simply returns the desired default value, but still no luck.</p>
  
  <p>Below is the ConstractResolver code:</p>
  
  <pre><code>public class DataControllerContractResolver : DefaultContractResolver
  {
      ///The desired default value
      private readonly IDataController _dataController;
  
      private readonly Type _dataControllerType;
      private readonly JsonConverter&lt;IDataController&gt; _converter;
  
      public DataControllerContractResolver(IDataController dataController)
      {
          _dataController = dataController;
          _dataControllerType = dataController.GetType();
          _converter = SimpleJsonConverter&lt;IDataController&gt;.From((reader, controller, arg3) =&gt; _dataController, (writer, controller, arg3) =&gt; {});
      }
  
      protected override IList&lt;JsonProperty&gt; CreateConstructorParameters(ConstructorInfo constructor, JsonPropertyCollection memberProperties)
      {
          var props = base.CreateConstructorParameters(constructor, memberProperties);
  
          foreach (var prop in memberProperties.Where(p =&gt; p.PropertyType.IsAssignableFrom(_dataControllerType)).ToList())
          {
              prop.DefaultValue = _dataController;
              prop.Converter = _converter;
              prop.DefaultValueHandling = DefaultValueHandling.Populate;
              prop.Ignored = false;
          }
  
          foreach (var prop in props.Where(p =&gt; p.PropertyType.IsAssignableFrom(_dataControllerType)).ToList())
          {
              prop.DefaultValue = _dataController;
              prop.Converter = _converter;
              prop.DefaultValueHandling = DefaultValueHandling.Populate;
              prop.Ignored = false;
          }
  
  
          return props;
      }
  
      protected override JsonProperty CreatePropertyFromConstructorParameter(JsonProperty matchingMemberProperty, ParameterInfo parameterInfo)
      {
          var prop = base.CreatePropertyFromConstructorParameter(matchingMemberProperty, parameterInfo);
  
          if (prop.PropertyType.IsAssignableFrom(_dataControllerType))
          {
              prop.DefaultValue = _dataController;
              prop.Converter = _converter;
              prop.MemberConverter = _converter;
              prop.DefaultValueHandling = DefaultValueHandling.Populate;
              prop.Ignored = false;
          }
  
          return prop;
      }
  
      protected override JsonObjectContract CreateObjectContract(Type objectType)
      {
          var contract = base.CreateObjectContract(objectType);
          return contract;
      }
  }
  </code></pre>