In appsettings.json
{
\"MyArray\": [
\"str1\",
\"str2\",
\"str3\"
]
}
In Startup.cs
If you have array of complex JSON objects like this:
{
"MySettings": {
"MyValues": [
{ "Key": "Key1", "Value": "Value1" },
{ "Key": "Key2", "Value": "Value2" }
]
}
}
You can retrieve settings this way:
var valuesSection = configuration.GetSection("MySettings:MyValues");
foreach (IConfigurationSection section in valuesSection.GetChildren())
{
var key = section.GetValue("Key");
var value = section.GetValue("Value");
}