title: System.Text.Json serialize derived class property
body: <p>I'm migrating a project from <code>Newtonsoft.Json</code> to <code>System.Text.Json</code> in .NET 5.</p>
  <p>I have class:</p>
  <pre class="lang-cs prettyprint-override"><code>abstract class Car
  {
      public string Name { get; set; } = &quot;Default Car Name&quot;;
  }
  
  class Tesla : Car
  {
      public string TeslaEngineName { get; set; } = &quot;My Tesla Engine&quot;;
  }
  </code></pre>
  <p>I tried:</p>
  <pre class="lang-cs prettyprint-override"><code>var cars = new List&lt;Car&gt; 
  { 
      new Tesla(),
      new Tesla(),
      new Tesla()
  };
  
  var json = JsonSerializer.Serialize(cars);
  
  Console.WriteLine(json);
  </code></pre>
  <p>The output is:</p>
  <pre class="lang-json prettyprint-override"><code>[
    {&quot;Name&quot;:&quot;Default Car Name&quot;},
    {&quot;Name&quot;:&quot;Default Car Name&quot;},
    {&quot;Name&quot;:&quot;Default Car Name&quot;}
  ]
  </code></pre>
  <p>Which lost my property: <code>TeslaEngineName</code>.</p>
  <p>So how can I serialize derived an object with all properties?</p>