Как читать вложенные объекты из настроек приложения?C#

Место общения программистов C#
Anonymous
Как читать вложенные объекты из настроек приложения?

Сообщение Anonymous »


In my .NET Core application, I am trying to read data from appsettings.json.

I have this configuration in appsettings.json:

"ServiceDetails": { "CellDetails": { "ScenarioName": [ 4, 5 ], "ServiceName": [ 5, 5 ] } } I would like to read this and convert into list like this:

scenario name, 4,5 service name, 5,5 Model class for the above list:

public class CellDetails { public string CellKeyValue { get; set; } public int Row { get; set; } public int Column { get; set; } } I am trying something like this

var serverUrl = configuration.GetSection("ServiceDetails") .GetSection("CellDetails").Get(); Above code doesn't work, can someone help me to fix this? Any help would be appreciated.


Источник: https://stackoverflow.com/questions/781 ... ppsettings

Вернуться в «C#»