0
我试图用NewtonSoft JsonConvert
转换ListItemCollection
在Web Service
。listitemcollection jsonconvert serializeObject失败
[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"]
文本包含,值丢失。任何想法为什么发生这种情况?
我实际上最终将集合转换为List。我想我的问题和我惊讶的是,当我没有任何问题序列化更复杂的项目时,它为什么不能开箱即用。 –
Bindrid