I\'d like to store a one dimensional string array as an entry in my appSettings. I can\'t simply separate elements with , or | because
ASP.Net Core supports it binding a list of strings or objects.
For strings as mentioned, it is possible to retrieve it through AsEnumerable().
Or a list of objects via Get(). The sample is below.
appsettings.json
{
...
"my_section": {
"objs": [
{
"id": "2",
"name": "Object 1"
},
"id": "2",
"name": "Object 2"
}
]
}
...
}
Class to represent the object
public class MyObject
{
public string Id { get; set; }
public string Name { get; set; }
}
Code to retrieve from appsettings.json
Configuration.GetSection("my_section:objs").Get>();