0

I have following configuration file

{
  "MyNamespace.Plugin": {
    "Setting": {
      "Path": "test"
    }
  }
}

And wrote following code to read it

var config = new ConfigurationBuilder()
                .AddJsonFile("settings.json")
                .Build();

var configuration = config.GetSection("MyNamespace.Plugin");

Setting setting = configuration.GetValue<Setting>("Setting");

However, I always get null for setting. Not sure where I am going wrong.

resp78
  • 1,414
  • 16
  • 37

1 Answers1

0

I am able to do following

var configuration = settings.Configuration.GetSection("MyNamespace.Plugin");

var settingSection = configuration.GetSection("Setting");
var setting = new Setting();
settingSection.Bind(setting);

Credit to the question raised at Microsoft.Configuration.Extensions: How to get section / complex value as json string?

resp78
  • 1,414
  • 16
  • 37