title: Throw exception when converting dynamic object to json with System.Text.Json.Serialization
body: <p>I want to convert a dynamic object to json string. It worked perfect when I used Newtonsoft.Json at past. when I upgraded .net core to 3.0 and used System.Text.Json instead, it was bad.</p>
  
  <p>See the code:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Dynamic;
  namespace ConsoleApp
  {
      class Program
      {
          static void Main(string[] args)
          {
              dynamic product = new ExpandoObject();
              product.ProductName = "Elbow Grease";
              product.Enabled = true;
              product.Price = 4.90m;
              product.StockCount = 9000;
              product.StockValue = 44100;
              product.Tags = new string[] { "Real", "OnSale" };
  
              // Will output: { "ProductName":"Elbow Grease","Enabled":true,"Price":4.90,
              // "StockCount":9000,"StockValue":44100,"Tags":["Real","OnSale"]}
              var json1 = Newtonsoft.Json.JsonConvert.SerializeObject(product);
              Console.WriteLine(json1);
  
              // Both will throw exception: System.InvalidCastException:“Unable to
              // cast object of type '&lt;GetExpandoEnumerator&gt;d__51' to type
              // 'System.Collections.IDictionaryEnumerator'.”
              var json2 = System.Text.Json.JsonSerializer.Serialize(product);
              Console.WriteLine(json2);
              var json3 = System.Text.Json.JsonSerializer.Serialize&lt;IDictionary&lt;string, object&gt;&gt;(product as IDictionary&lt;string, object&gt;);
              Console.WriteLine(json3);
  
              Console.ReadKey();
          }
      }
  }
  </code></pre>
  
  <p>If I want to persist using System.Text.Json to convert the dynamic object because I hear that it is faster then other json converts, how could I do?</p>