How to hardcode and read a string array in appSettings.json?

Indexer of a section returns string by exact key match, and since array values have keys with postfixes, there is nothing to match given key and you are getting null.

To get it work you may use something like this

var section = configuration.GetSection($"{APP_SETTINGS_SECTION}:{APP_SETTINGS_KEY}");
var folders = section.Get<string[]>();

And check this for more options.

Leave a Comment