title: IConfigurationRoot and type information
body: <p>Per this <a href="https://stackoverflow.com/questions/62713523">Using System.Text.Json to Serialize an IConfiguration back to Json</a> it seems that the limited type information that you <em>can</em> put into JSON is discarded.</p>
  <blockquote>
  <p>You seem to be under the impression that IConfiguration objects are storing ints, bools, etc. (for example) corresponding to the JSON Element type. This is incorrect. All data within an IConfiguration is stored in stringified form. The base Configuration Provider classes all expect an IDictionary&lt;string, string&gt; filled with data. Even the JSON Configuration Providers perform an explicit ToString on the values.</p>
  </blockquote>
  <p>I noticed this when I addressed the problem posed in that question with this extension method.</p>
  <pre class="lang-cs prettyprint-override"><code>using System.Collections.Generic;
  using System.Dynamic;
  using Microsoft.Extensions.Configuration;
  
  public static class ExtendConfig
  {
    public static dynamic AsDynamic(this IConfigurationRoot cr)
    {
      var result = new ExpandoObject();
      var resultAsDict = result as IDictionary&lt;string, object&gt;;
      foreach (var item in cr.AsEnumerable())
      {
        resultAsDict.Add(item.Key, item.Value);
      }
      return result;
    }
  }
  </code></pre>
  <p>This method reconstructs the graph but everything is now a string.</p>
  <p>I could write my own parser and apply it to the original JSON string but that's a bit dire. Is there any way I can get this metadata so I can improve the fidelity of merged configs? I'm passing it through for consumption by JS which does notice the difference.</p>
  <p>Merging is why I'm using the config extensions builder.</p>