我的网络服务返回 json 数据,如下所示,但我想要的就像在 2nd CodeSnipts 中一样。我的网络服务和课程如下所示。
{ "ShowID": 10107,
"StartTime": "3:00 PM",
"MovieID": 13,
"Movie": "Bhaag Milkha Bhaag ",
"Screen": "CDC SCreen2",
"MediaPath": "bmb1_568962.jpg"
},{ "ShowID": 115,
"StartTime": "6:00 PM",
"MovieID": 13,
"Movie": "Bhaag Milkha Bhaag ",
"Screen": "CDC SCreen2",
"MediaPath": "bmb1_568962.jpg"
},{ "ShowID": 110,
"StartTime": "9:00 PM",
"MovieID": 13,
"Movie": "Bhaag Milkha Bhaag ",
"Screen": "CDC SCreen2",
"MediaPath": "bmb1_568962.jpg"
}
但我想作为
{
"MovieID": 13,
"Movie": "Bhaag Milkha Bhaag ",
"Screen": "CDC SCreen2",
"MediaPath": "bmb1_568962.jpg",
"ShowInfo": [
{
"ShowID": 10107,
"StartTime": "3:00 PM"
},
{
"ShowID": 115,
"StartTime": "6:00 PM"
},
{
"ShowID": 110,
"StartTime": "9:00 PM"
}
]
}
我的 Webservice 的 c# 代码为
[WebMethod]
public string NowShowingGetList(DateTime ShowDate)
{
HomeController obj = new HomeController();
JavaScriptSerializer js = new JavaScriptSerializer();
string retJSON = js.Serialize(obj.NowShowingGetList(ShowDate));
return retJSON;
}
类为
public class NowShowingInfo
{
public int ShowID { get; set; }
public string StartTime { get; set; }
public int MovieID { get; set; }
public string Movie { get; set; }
public string Screen { get; set; }
public string MediaPath { get; set; }
}
这里obj.NowShowingGetList(ShowDate)
提前返回列表Thankyou。