Microsoft.Extensions.Configuration binding dictionary with colons in key
<p>I am having trouble using <code>Microsoft.Extensions.Configuration</code> to bind a dictionary that contains keys that have colon <code>:</code> in them.</p>

<p>I have done an example that has a dictionary "GoodErrorMappings" which do not contain any colon in the key. These are mapped correctly.</p>

<p>I have created another dictionary "BadErrorMappings" that has a colon in the key. This dictionary seems to not be mapped correctly after it sees the first colon in the dictionary key.</p>

<p>I have had a quick look in the source and cannot see an obvious way to override the colon as a delimiter.</p>

<p>Any help would be appreciated.</p>

<p><strong>Doco:</strong>
<a href="https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration" rel="noreferrer">https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration</a></p>

<p><strong>Assembly version:</strong>
"Microsoft.NETCore.App"
"1.1.0"</p>

<p><strong>C# Code:</strong></p>

<pre><code>using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;

namespace OptionsTest
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var builder = new ConfigurationBuilder()
                .SetBasePath(Directory.GetCurrentDirectory())
                .AddJsonFile("appsettings.json");

            var config = builder.Build();

            var services = new ServiceCollection().AddOptions();

            services.Configure&lt;ApiConfig&gt;(x =&gt; config.GetSection("ApiConfig").Bind(x));

            var apiConfig = services.BuildServiceProvider().GetService&lt;IOptions&lt;ApiConfig&gt;&gt;().Value;

            Debug.WriteLine(string.Format("\r\nGoodErrorMappings: {0}", JsonConvert.SerializeObject(apiConfig.GoodErrorMappings, Formatting.Indented)));
            Debug.WriteLine(string.Format("\r\nBadErrorMappings: {0}", JsonConvert.SerializeObject(apiConfig.BadErrorMappings, Formatting.Indented)));

            Console.ReadLine();
        }
    }

    public class ApiConfig
    {
        public Dictionary&lt;string, ErrorMapping&gt; GoodErrorMappings { get; set; } = new Dictionary&lt;string, ErrorMapping&gt;();
        public Dictionary&lt;string, ErrorMapping&gt; BadErrorMappings { get; set; } = new Dictionary&lt;string, ErrorMapping&gt;();
    }

    public class ErrorMapping
    {
        public int HttpStatusCode { get; set; }
        public int ErrorCode { get; set; }
        public string Description { get; set; }
    }
}
</code></pre>

<p><strong>AppSettings.json:</strong></p>

<pre><code>{
  "ApiConfig": {
    "GoodErrorMappings": {
      "/SOMEVALUE/BLAH.123": {
        "httpStatusCode": "500",
        "errorCode": "110012",
        "description": "Invalid error description 1"
      },
      "/SOMEVALUE/BLAH.456": {
        "httpStatusCode": "500",
        "errorCode": "110013",
        "description": "Invalid error description 2"
      }
    },
    "BadErrorMappings": {
      "/SOMEVALUE/BLAH:123": {
        "httpStatusCode": "500",
        "errorCode": "110012",
        "description": "Invalid error description 1"
      },
      "/SOMEVALUE/BLAH:456": {
        "httpStatusCode": "500",
        "errorCode": "110013",
        "description": "Invalid error description 2"
      }
    }
  }
}
</code></pre>

<p><strong>Output:</strong></p>

<pre><code>GoodErrorMappings: {
  "/SOMEVALUE/BLAH.123": {
    "HttpStatusCode": 500,
    "ErrorCode": 110012,
    "Description": "Invalid error description 1"
  },
  "/SOMEVALUE/BLAH.456": {
    "HttpStatusCode": 500,
    "ErrorCode": 110013,
    "Description": "Invalid error description 2"
  }
}

BadErrorMappings: {
  "/SOMEVALUE/BLAH": {
    "HttpStatusCode": 0,
    "ErrorCode": 0,
    "Description": null
  }
}
</code></pre>