title: How can I create a custom converter similar to Newtonsoft using system.text.json?
body: <p>I recently spent a lot of time upgrading my old asp.net 4.6 project to .Net 6.</p>
  <p>I have almost everything working, but I am having trouble using <code>System.Text.Json</code> in place of Newtonsoft.</p>
  <p>In my Startup.cs I ham trying to use a Custom Converter like this:</p>
  <pre><code>services.AddMvc()
      .AddJsonOptions(opts =&gt; {
          //custom converter for PlayerItemDto
          opts.JsonSerializerOptions.Converters.Add(new PlayerItemConverter());
      });
      
      
  </code></pre>
  <p>Here is where I am trying to do the conversion.  This is all Newtonsoft now, and I am not sure if this will work in <code>System.Text.Json</code>.</p>
  <p>Specifically, I can't find anything in <code>System.Text.Json</code> that replaces <code>var obj = JObject.Load(reader);</code> and <code>options.Populate(obj.CreateReader(), retval)</code></p>
  <p>Does anyone know if it's possible?</p>
  <p>Here is my converter class:</p>
  <pre><code>public class PlayerItemConverter : CustomCreationConverter&lt;PlayerItemDto&gt;
  {
      public PlayerItemDto Create(String morality)
      {
          switch (morality) {
              case &quot;bad&quot;:
                  return new MonsterTypeDto();
              case &quot;good&quot;:
                  return new LeaderTypeDto();
          }
      }
  
      public override Object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
      {
          var obj = JObject.Load(reader);
          var morality = (String) obj.Property(&quot;morality&quot;);
          var retval = Create(morality);
          serializer.Populate(obj.CreateReader(), retval);
          return retval;
      }
  }
  </code></pre>