Skip to content

ConfigurationBuilder - Configuration.Json: Binding a Dictionary<string,string> error when Key contains an string url like http://www.google.es #42643

@ghost

Description

Describe the bug

Im reading a json file to a dictionary<string,string> like:

{
  "auths": {
    "https://www.google.es": {
      "uri": "https://www.google.es"
    }
  }
}

having the POCO class

public class MyClass
{
        [ConfigurationProperty("auths", IsRequired = false)]
        public Dictionary<string, OtherObject> Auths { get; set; }
}

When i load it using ConfigurationRoot like

public MyClass Read()
        {
            IConfigurationRoot configuration =
                new ConfigurationBuilder()
                    .AddJsonFile("path_to_json_file", optional: true, reloadOnChange: true)
                .Build();

            // Try Parse and return (if will exception in case of binding error)
            var _settings= new MyClass();
            configuration.Bind(_settings);

            return _settings;
        }

The issue is that the Dictionary item contains https only on the Key property. Looks like it's ignoring or having issues with https://.....

Not sure if it's an intended feature or a bug.

To Reproduce

Steps to reproduce the behavior:

  1. Using version '3.1.8' of package 'Microsoft.Extensions.Configuration.Json'
  2. Run this code 'with files in description'
  3. See error in the screenshot attached

Expected behavior

Dictionary Key Item should contains https://www.google.es

Screenshots

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    api-needs-workAPI needs work before it is approved, it is NOT ready for implementationarea-Extensions-ConfigurationenhancementProduct code improvement that does NOT require public API changes/additions

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions