https://www.cnblogs.com/knowledgesea/p/7079880.html
引入Nuget的两个类库
Microsoft.Extensions.Configuration Microsoft.Extensions.Configuration.Json
使用
var builder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json"); var configurationRoot = builder.Build(); var motherNameSection = configurationRoot.GetSection("mother").GetSection("name");
-------------------------------------------------------------------------------------------------------------------------------------------------------
如果我们要读取Bin的Value值,这样处于多层嵌套的json
只要在StartUp中加上这个-----》层级关系用" : "英文冒号隔开就是了
//注册appsetting的值
services.Configure<AppSetting>(_configuration.GetSection("Zhu:Kai"));