假设我有一个config.json这样的:
{
"CustomSection": {
"A": 1,
"B": 2
}
}
Run Code Online (Sandbox Code Playgroud)
我知道我可以使用IConfiguration对象来获取特定设置,即 ,configuration.Get("CustomSection:A")但是我可以获取整个层次结构(任何类型 - 即使是原始字符串也可以)?当我尝试时configuration.Get("CustomSection"),我得到了null结果,所以我认为默认情况下不支持。
我的用例是一次获取整个配置字典,而不必获取每个单独的设置 - 在编译时可能不知道某些属性。