var settings = new ConfigurationBuilder() .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) .Build(); string connectionString = settings.GetConnectionString("MyDbConnection");
var settings = new ConfigurationBuilder() .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) .Build(); string myValue = settings.GetSection("MyCustomSection")["MyValue"];In this example, the value of "MyValue" property in "MyCustomSection" section of appsettings.json file is retrieved using the GetSection method and indexer. The package library for SettingsClient is Microsoft.Extensions.Configuration.