首页 > 解决方案 > 为 appsettings.json 中的属性添加值并将其转换为 json

问题描述

在 appsettings.json 的 ASP.NET Core Web 应用程序中,我有:

"SVAML" : {
        'instructions':[
         {
            'name' : 'PlayFiles',
            'ids' : ['inside controller put string value here']
         }
        ],

        'action': {
            'name' : 'Continue'
        }
}

在我的控制器内部,我可以使用 _configuration["SVAML"] 访问它的值,我需要将值放入控制器中并在放入此值后将其作为 json 发送,例如 JObject.Parse(_configuration["SVAML"])。 toString() 作为请求的主体。

标签: c#asp.net-core.net-core

解决方案


为 SVAML 创建一个类并对其进行序列化。


推荐阅读