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