Read json array from appsettings c#
Create an object model to hold the values
public class ProcessStep { public string name { get; set; } public bool enabled { get; set; }}
Then get the array from the section using Get<T>
ProcessStep[] procSteps = _configurationRoot .GetSection("steps") .Get<ProcessStep[]>();
ASP.NET Core 1.1 and higher can use
Get<T>
, which works with entire sections.Get<T>
can be more convenient than usingBind
Reference Configuration in ASP.NET Core: Bind to an object graph