【发布时间】:2015-12-09 01:00:59
【问题描述】:
我尝试使用NewtonSoft JsonConvert 将ListItemCollection 转换为Web Service。
[WebMethod(EnableSession = true)]
public string TestNewtonSoft()
{
System.Web.UI.WebControls.ListItemCollection coll = new System.Web.UI.WebControls.ListItemCollection();
coll.Add(new System.Web.UI.WebControls.ListItem("item one", "1"));
coll.Add(new System.Web.UI.WebControls.ListItem("item two", "2"));
coll.Add(new System.Web.UI.WebControls.ListItem("item three", "3"));
coll.Add(new System.Web.UI.WebControls.ListItem("item four", "4"));
coll.Add(new System.Web.UI.WebControls.ListItem("item five", "5"));
string aList = Newtonsoft.Json.JsonConvert.SerializeObject(coll);
return aList;
}
结果集是
["item one","item two","item three","item four","item five"]
包含文本,丢失值。任何想法为什么会发生这种情况?
【问题讨论】: