【发布时间】:2017-08-01 06:11:20
【问题描述】:
我正在尝试从appsettings.json 文件中读取值列表。我可以毫无问题地读取Logging 值,但列表值(即Servers)为空:
appsettings.json:
{
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
},
"Servers": [
"SCHVW2K12R2-DB",
"SCHVW2K12R2-DB\\MSSQL2016",
"SCHVW2K8R2-DB"
]
}
对象类:
public class AppSettingsConfiguration
{
public Logging Logging { get; set; }
public Servers Servers { get; set; }
}
//Logging Objects
public class Logging
{
public bool IncludeScopes { get; set; }
public LogLevel LogLevel { get; set; }
}
public class LogLevel
{
public string Default { get; set; }
public string System { get; set; }
public string Microsoft { get; set; }
}
//Server Objects
public class Servers
{
public List<string> Names { get; set; }
}
【问题讨论】:
标签: c# json asp.net-core