在ASP.NET Core 2.2页面的ASP.NET Core中显示JSON的漂亮打印格式
我无法查看格式良好的json。我正在使用asp.net core 2.2。我从jsonb格式的postgresql数据库中读取它,但在razor页面中,它一直将其视为字符串 我添加到startup.cs在ASP.NET Core 2.2页面的ASP.NET Core中显示JSON的漂亮打印格式,json,asp.net-core-2.2,pretty-print,Json,Asp.net Core 2.2,Pretty Print,我无法查看格式良好的json。我正在使用asp.net core 2.2。我从jsonb格式的postgresql数据库中读取它,但在razor页面中,它一直将其视为字符串 我添加到startup.cs enter code here services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2) .AddJsonOptions(options => options.Serial
enter code here
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2)
.AddJsonOptions(options => options.SerializerSettings.Formatting = Formatting.Indented)
当我在剃须刀页面上读到它时,我使用:
@foreach (var item in Model.Risposta){ <tr> <td> @Html.DisplayFor(m => item.Response) </td> </tr>
}
但我有同样的结果。
谢谢
@(Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(Model.Risposta)))