title: Why does System.Text Json Serialiser not serialise this generic property but Json.NET does?
body: <p>I have the following situation. I have simplified the problem into the following example, although my real situation is more complicated.</p>
  
  <p><strong>System.Text.Json</strong> does not serialise the object fully but <strong>Newtonsoft Json.NET</strong> does.</p>
  
  <p>Suppose I have the following class structure.</p>
  
  <pre><code>public class A
  {
      public string AProperty { get; set; } = "A";
  }
  
  public class A&lt;T&gt; : A where T : class, new()
  {
      public T TObject { get; set; } = new T();
  }
  
  public class B
  {
      public string BProperty { get; set; } = "B";
  }
  
  public class B&lt;T&gt; : B where T : class, new()
  {
      public T TObject { get; set; } = new T();
  }
  
  public class C
  {
      public string CProperty { get; set; } = "C";
  }
  </code></pre>
  
  <p>Here is a simple .NET Core program:</p>
  
  <pre><code>public class Program
  {
      private static void Main(string[] args)
      {
          var obj = new A&lt;B&gt; { TObject = new B&lt;C&gt;() };
  
          var systemTextSerialized = JsonSerializer.Serialize(obj);
          var newtonsoftSerialized = JsonConvert.SerializeObject(obj);
      }
  }
  </code></pre>
  
  <p>The serialised results are as follows:</p>
  
  <h2>System.Text.Json</h2>
  
  <pre><code>{
    "TObject": {
      "BProperty": "B"
    },
    "AProperty": "A"
  }
  
  </code></pre>
  
  <h2>Newtonsoft</h2>
  
  <pre><code>{
    "TObject": {
      "TObject": {
        "CProperty": "C"
      },
      "BProperty": "B"
    },
    "AProperty": "A"
  }
  </code></pre>
  
  <p>Due to the structure of my application, I don't know the generic parameter of <code>B</code>. I only know that it is an <code>A&lt;B&gt;</code>. The actual <code>TObject</code> of <code>B</code> is not known until runtime.</p>
  
  <p>Why do these two serialisation methods differ? Is there a way to get System.Text.Json to serialise the object fully, or do I need to write a custom converter?</p>