I have an appsettings.json file which looks like this:
{
"someSetting": {
"subSettings": [
"one",
"two",
"three"
]
}
}
When I build my configuration root, and do something like config["someSetting:subSettings"]
it returns null and the actual settings available are something like this:
config["someSettings:subSettings:0"]
Is there a better way of retrieving the contents of someSettings:subSettings
as a list?
Assuming your appsettings.json
looks like this:
{
"foo": {
"bar": [
"1",
"2",
"3"
]
}
}
You can extract the list items like so:
Configuration.GetSection("foo:bar").Get<List<string>>()