title: How can I provide optional settings for my 'custom' JsonDotNetResult?
body: <p>I have an alternate <code>JsonResult</code>, being the class below, to provide a better JSON serializer than the default for MVC Web Apps (irrelevant bits omitted):</p>
  
  <pre><code>public class JsonDotNetResult : JsonResult
  {
      public readonly JsonSerializerSettings Settings = new JsonSerializerSettings
      {
          PreserveReferencesHandling = PreserveReferencesHandling.Arrays,
          ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
          ContractResolver = new CamelCasePropertyNamesContractResolver(),
          Converters = new List&lt;JsonConverter&gt; { new StringEnumConverter() }
      };
  
      public override void ExecuteResult(ControllerContext context)
      {
          ...
          var response = context.HttpContext.Response;
          ...
          response.Write(JsonConvert.SerializeObject(Data, Settings));
      }
  }
  </code></pre>
  
  <p>Then I have an overload for <code>Controller.Json</code>, declared as:</p>
  
  <pre><code>protected JsonResult Json(object data, string contentType, Encoding contentEncoding, JsonRequestBehavior behavior, JsonSerializerSettings settings = null)
  </code></pre>
  
  <p>but I don't have the existing default settings set in the <code>Settings</code> field of <code>JsonDotNetResult</code>, so if I pass in a new <code>JsonSerializerSettings</code>, with a few properties set by the caller, I will overwrite all the properties of the <code>Settings</code> object with the default values for <code>JsonSerializerSettings</code>, and with the new values provided by the caller. The latter being desired, the former I'm trying to avoid.</p>
  
  <p>How can I pass in a subset of <code>JsonSerializerSettings</code> property values and apply them to the <code>Settings</code> object in <code>JsonDotNetResult</code>? My best (and first) effort is to loop through the properties of the default <code>Settings</code> object and compare them to property values on a new <code>JsonSerializerSettings</code> object passed by the user, and where the differ, set the value on <code>Settings</code> to the value supplied by the user.</p>