title: .Net Core 3.0 JsonSerializer populate existing object
body: <p>I'm preparing a migration from ASP.NET Core 2.2 to 3.0.</p>
  <p>As I don't use more advanced JSON features (but maybe one as described below), and 3.0 now comes with a built-in namespace/classes for JSON, <code>System.Text.Json</code>, I decided to see if I could drop the previous default <code>Newtonsoft.Json</code>.<br />
  <em>Do note, I'm aware that <code>System.Text.Json</code> will not completely replace <code>Newtonsoft.Json</code>.</em></p>
  <p>I managed to do that everywhere, e.g.</p>
  <pre><code>var obj = JsonSerializer.Parse&lt;T&gt;(jsonstring);
  
  var jsonstring = JsonSerializer.ToString(obj);
  </code></pre>
  <p>but in one place, where I populate an existing object.</p>
  <p>With <code>Newtonsoft.Json</code> one can do</p>
  <pre><code>JsonConvert.PopulateObject(jsonstring, obj);
  </code></pre>
  <hr />
  <p>The built-in <code>System.Text.Json</code> namespace has some additional classes, like <code>JsonDocumnet</code>, <code>JsonElement</code> and <code>Utf8JsonReader</code>, though I can't find any that take an existing object as a parameter.</p>
  <p>Nor am I experienced enough to see how to make use of the existing one's.</p>
  <p>There might be <a href="https://github.com/dotnet/corefx/issues/37627" rel="noreferrer">a possible upcoming feature in .Net Core</a>  (thanks to <a href="https://stackoverflow.com/users/3445247/mustafa-gursel">Mustafa Gursel</a> for the link), but meanwhile (and what if it doesn't),...</p>
  <p>...I now wonder, is it possible to achieve something similar as what one can do with <code>PopulateObject</code>?</p>
  <p>I mean, is it possible with any of the other <code>System.Text.Json</code> classes to accomplish the same, and update/replace only the properties set?,... or some other clever workaround?</p>
  <hr />
  <p>Here is a sample input/output of what I am looking for, and it need to be generic as the object passed into the deserialization method is of type <code>&lt;T&gt;</code>). I have 2 Json string's to be parsed into an object, where the first have some default properties set, and the second some, e.g.</p>
  <p><em>Note, a property value can be of any other type than a <code>string</code></em>.</p>
  <p>Json string 1:</p>
  <pre><code>{
    &quot;Title&quot;: &quot;Startpage&quot;,
    &quot;Link&quot;: &quot;/index&quot;,
  }
  </code></pre>
  <p>Json string 2:</p>
  <pre><code>{
    &quot;Head&quot;: &quot;Latest news&quot;
    &quot;Link&quot;: &quot;/news&quot;
  }
  </code></pre>
  <p>Using the 2 Json strings above, I want an object resulting in:</p>
  <pre><code>{
    &quot;Title&quot;: &quot;Startpage&quot;,
    &quot;Head&quot;: &quot;Latest news&quot;,
    &quot;Link&quot;: &quot;/news&quot;
  }
  </code></pre>
  <p>As seen in above sample, if properties in the 2nd has values/is set, it replace values in the 1st (as with &quot;Head&quot; and &quot;Link&quot;), if not, existing value persist (as with &quot;Title&quot;)</p>