title: Serialize object contents and not an entire property
body: <p><strong>Background</strong></p>
  <p>I have an application that returns an array of Config models from a SQL database.
  This Config model contains a string property called &quot;CustomConfig&quot; which holds raw JSON specific to each row. The model also contains a JObject property called &quot;CustomConfigObject&quot; which is essentially a deserialized version of the JSON string.
  This was done in order to keep the SQL Table design simple.</p>
  <p>The ultimate point of these rows is to form a large JSON blob used to configure a client experience.</p>
  <p><strong>The problem</strong></p>
  <p>When all of the post processing has been performed on the Config models, they are then serialised using Newtonsoft.</p>
  <p>Upon serialization, the object looks like this -</p>
  <pre><code>{
    id: 0,
    name: &quot;Title&quot;,
    customConfigObject: {
      items: [...],
      href: &quot;http://...&quot;,
      header: &quot;&quot;,
      orientation: 0,
      apiKey: 123
    }
  }
  </code></pre>
  <p>I am wondering if there is a way of extracting the value of the property during serialization so that the result looks like this instead (notice there is no &quot;customConfigObject&quot;) -</p>
  <pre><code>{
    id: 0,
    name: &quot;Title&quot;,
    items: [...],
    href: &quot;http://...&quot;,
    header: &quot;&quot;,
    orientation: 0,
    apiKey: 123
  }
  </code></pre>
  <p>I have looked into Custom Convertors but I'm not sure it produces the needed outcome.</p>
  <p>Any help on this one would be hugely appreciated as out current workaround is to define each possible property of &quot;CustomConfigObject&quot; with a getter to return the sub-property.</p>
  <p>Many thanks!</p>
  <p>Basic example of the issue -</p>
  <pre><code>using System;
  using System.Collections.Generic;
  using Newtonsoft.Json;
  using Newtonsoft.Json.Serialization;
  using Newtonsoft.Json.Linq;
                      
  public class Program
  {
      public static void Main()
      {
          Console.WriteLine(&quot;Hello World&quot;);
          
          var parent = new Config(){
              Name = &quot;Parent&quot;,
              Description = &quot;desc&quot;,
              Children = new List&lt;Config&gt;()
          };
          
          var child1 = new Config(){
              Name = &quot;Child&quot;,
              Description = &quot;desc&quot;,
              CustomConfig = &quot;{ href: 'http://...', header: '...', orientation: 0, apiKey: 123 }&quot;
          };
          
          var child2 = new Config(){
              Name = &quot;Child 2&quot;,
              Description = &quot;desc&quot;,
              CustomConfig = &quot;{ href: 'http://...', header: 'things', orientation: 1, apiKey: 345 }&quot;
          };
          
          parent.Children.Add(child1);
          parent.Children.Add(child2);
          
          DefaultContractResolver contractResolver = new DefaultContractResolver
              {
                  NamingStrategy = new CamelCaseNamingStrategy()
              };
  
              var json = JsonConvert.SerializeObject(parent, new JsonSerializerSettings
              {
                  ContractResolver = contractResolver,
                  Formatting = Formatting.Indented,
                  NullValueHandling = NullValueHandling.Ignore
              });
          Console.WriteLine(json);
      }
  }
  
  
  public class Config{
      public string Name { get; set; }
      public string Description { get; set; }
      [JsonIgnore]
      public string CustomConfig { get; set; }
      public JObject CustomConfigObject
          {
              get
              {
                  if (!string.IsNullOrEmpty(CustomConfig))
                  {
                      return JObject.Parse(CustomConfig);
                  }
  
                  return null;
              }
          }
      public List&lt;Config&gt; Children { get; set; }
  }
  </code></pre>