1
我有一個C#對象(下),我試圖發送到我的JavaScript。c# - > JavaScript,JSON解碼丟失屬性
我的問題是,儘管我可以迭代列表中的項目,但我無法獲取字符串屬性('期間')。
在JS中引用對象根本沒有顯示任何屬性。 JSON-編碼在C#中,我仍然可以看到該屬性只是返回給調用者之前(懸停在下面函數的結果變量):
[OutputCache(Duration = 0, VaryByParam = "None")]
public JsonResult GetRankingList()
{
Response.ContentType = "text/javascript";
var user = _userService.GetUserByPrincipal(User);
// Note, we do this while the user waits as we need to make progress in repeated calls to get the compared ranking list.
_businessLogicServiceMaintenance.PerformMaintenanceSteps();
//TODO: Replace with userid (Guid)
var rankingList = _presenterService.GetRankingListForDisplay(user);
if (rankingList == null)
return Json("");
var result = Json(rankingList);
return result;
}
如何在地球上,我可以突破這個?任何意見讚賞!
你的,安德斯,丹麥,
public class RankingListForDisplay : List<RankingListLine>
{
public string Period { get; set; }
}
你是如何從列表中創建JSON和究竟什麼是你把它返回給調用者之前,你所得到的結果呢? – drs9222 2010-04-20 16:42:48
您好drs, 對不起 - 沒有看到評論。 我編輯了這個問題來顯示被調用的c#代碼。 – 2010-04-26 18:27:08
什麼是您正在使用的JSON序列化程序? – 2010-04-26 18:31:32