0
我正在使用SQL Server 2016在我的数据集中的字符串字段中返回json数据。我没有任何转换就将json字符串传递给模型。我想列举我的JSON字符串场MVC剃刀一样:如何在MVC Razor foreach循环中枚举json字符串?
@foreach (var notification in Model.AccountSettings.EmailNotifications)
{
EmailNotifications为对象的JSON数组。
EmailNotifications = [{"EmailNotificationID":8,"EmailNotificationName":"Any new KLAS report is published.","IsSet":false},{"EmailNotificationID":9,"EmailNotificationName":"KLAS publishes a report in one of my areas of interest.","IsSet":false}]
要做到这一点的最佳方法是什么?
我的猜测是,将不得不把对象作为数组或东西。您可能还必须将每个项目投到其他项目。你为什么不想使用JSON.Net将其转换为对象? – Eonasdan
因此,您有'Model.AccountSettings.EmailNotifications'中的'EmailNotification'类对象列表?或者它只是一个STRING?你的字符串值是怎样的? – Shyju
是的,它只是一个字符串 – Rodney