title: System.Text.Json.JsonElement ToObject workaround
body: <p>I want to know the equivalent of the <code>ToObject&lt;&gt;()</code> method in <a href="https://www.newtonsoft.com/json/help/html/Introduction.htm" rel="nofollow noreferrer">Json.NET</a> for <em>System.Text.Json</em>.</p>
  <p>Using Json.NET you can use any <code>JToken</code> and convert it to a class. For example:</p>
  <pre class="lang-cs prettyprint-override"><code>var str = &quot;&quot;; // Some JSON string
  var jObj = JObject.Parse(str);
  var myClass = jObj[&quot;SomeProperty&quot;].ToObject&lt;SomeClass&gt;();
  </code></pre>
  <p>How would we be able to do this with .NET Core 3's new <code>System.Text.Json</code>?</p>
  <pre class="lang-cs prettyprint-override"><code>var str = &quot;&quot;; // Some JSON string
  var jDoc = JsonDocument.Parse(str);
  var myClass = jDoc.RootElement.GetProperty(&quot;SomeProperty&quot;). &lt;-- now what??
  </code></pre>
  <p>Initially, I was thinking I'd just convert the <code>JsonElement</code> that is returned in <code>jDoc.RootElement.GetPRoperty(&quot;SomeProperty&quot;)</code> to a string and then deserialize that string. But I feel that might not be the most efficient method, and I can't really find documentation on doing it another way.</p>