ASP.NET Core Get Json Array using IConfiguration

后端 未结 14 2115
失恋的感觉
失恋的感觉 2020-11-30 21:49

In appsettings.json

{
      \"MyArray\": [
          \"str1\",
          \"str2\",
          \"str3\"
      ]
}

In Startup.cs

14条回答
  •  眼角桃花
    2020-11-30 22:21

    You can get the array direct without increment a new level in the configuration:

    public void ConfigureServices(IServiceCollection services) {
        services.Configure>(Configuration.GetSection("MyArray"));
        //...
    }
    

提交回复
热议问题