Further from the StackOverflow question regarding Using IConfiguration worldwide in mvc6 . Commentary on accepted answer involves using
services.Configure<SomeOptions>(Configuration);
Now this works fine with the following code:
Class
public class SomeOptions { public string MyOption { get; set; } }
config.json
{ "MyOption": "OptionValue" }
Startup.cs
public Startup(IHostingEnvironment env) { Configuration = new Configuration() .AddJsonFile("config.json") .AddEnvironmentVariables(); } public void ConfigureServices(IServiceCollection services) { services.Configure<SomeOptions>(Configuration); }
However, the config.json file config.json not have any real structure, and I would like it to look more like:
{ "SomeOptions": { "MyOption": "OptionValue" } }
However, this does not bind the values ββinside the class. Is there any way to resolve this?
source share