title: Generic object -> object conversion for webapi
body: <p>This is a somewhat unique problem I think... I can solve it easily in js/ts but am kinda stuck trying to implement this in the c# solution if at all possible.</p>
  <p>Keeping it simple, so as not to write a novel here, I'm trying to improve some crappy json serialization.  It's using dictionaries within dictionaries currently and it's assy to parse in JS.  I wrote a TS library that &quot;unpacks&quot; the data into a more palatable format, but I'd love to move that server-side.  The model is an xml object with elements unkown to the application (because it's defined in a CMS and can be modified any time even while the app is running) and because Vendor, I'm stuck with c#.</p>
  <p>Super easy in JS - c#'s strong typing is killing me here.</p>
  <p>How would you create this addKvp function in c# (where element would be of type object, i assume)</p>
  <pre><code>function addKvp (element, key, value) { element[key] = value; }
  
  var abc = {};
  addKvp(abc, &quot;foo&quot;, &quot;bar&quot;);
  console.log(abc.foo);
  </code></pre>
  <p>where &quot;key&quot; is not a member of element.... <em>yet</em>.</p>
  <p>The other directions I could tackle this from is maybe by manipulating the json serialization somehow or putting my typescript library that does exactly this in a node express server and have it sit between the two - but this'd be the &quot;simplest&quot; solve, if it is possible.  It feels very against the c# grain.</p>