ASP.NETCORE_配置_Option方式二
1、配置文件加入json内容{ "name": "BeJson", "url": "http://www.bejson.com", "page": 88, "isNonProfit": true, "address": { "street": "科技园路.", "city": "江苏苏州", "country": "中国" }, "links": [ { "name": "Google", "url": "http://www.google.com" }, { "name": "Baidu", "url": "http://www.baidu.com" }, { "name": "SoSo", "url": "http://www.SoSo.com" } ]}

2、新增类与配置文件对应

3、加载配置到实例 services.Configure<json1>(Configuration);

4、view视图依赖注入@using Microsoft.Extensions.Options;@inject IOptions<ASP.NETCORE_配置_Json.json1> bbb@{ ViewData["Title"] = "test";}<h2>@bbb.Value.name</h2><h2>@bbb.Value.links[0].url</h2>

5、运行完成
