引入Nuget的兩個類庫 使用 ...
引入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");