Add this text to appsettings.json
{
"key1": "value1",
"key2": 2,
"subsectionKey": {
"suboption1": "subvalue1"
}
}
Now you can use this configuration in your app, in the way like this
public class Program
{
static public IConfigurationRoot Configuration { get; set; }
public static void Main(string[] args = null)
{
var builder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json");
Configuration = builder.Build();
Console.WriteLine($"option1 = {Configuration["key1"]}");
Console.WriteLine($"option2 = {Configuration["key2"]}");
Console.WriteLine(
$"option1 = {Configuration["subsectionKey:suboption1"]}");
}
}