title: System.Text.Json: Deserialize JSON with automatic casting
body: <p>Using .Net Core 3's new System.Text.Json JsonSerializer, how do you automatically cast types (e.g. int to string and string to int)? For example, this throws an exception because <code>id</code> in JSON is numeric while C#'s <code>Product.Id</code> is expecting a string:</p>
  
  <pre><code>public class HomeController : Controller
  {
      public IActionResult Index()
      {
          var json = @"{""id"":1,""name"":""Foo""}";
          var o = JsonSerializer.Deserialize&lt;Product&gt;(json, new JsonSerializerOptions
          {
              PropertyNameCaseInsensitive = true,
          });
  
          return View();
      }
  }
  
  public class Product
  {
      public string Id { get; set; }
      public string Name { get; set; }
  }
  </code></pre>
  
  <p>Newtonsoft's Json.Net handled this beautifully. It didn't matter if you were passing in a numeric value while C# was expecting a string (or vice versa), everything got deserialized as expected. How do you handle this using System.Text.Json if you have no control over the type format being passed in as JSON?</p>