我尝试过许多反序列化LINQO对象的方法,但是每个方法都失败了。下面是最后一个代码的示例。
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(SalesNetData.Country));
string xmlData = Session["CCC"].ToString();
byte[] byteArray = new byte[xmlData.Length];
byteArray = encoding.GetBytes(xmlData);
MemoryStream stream1 = new MemoryStream(byteArray);
SalesNetData.Country country = (SalesNetData.Country)ser.ReadObject(stream1);
Console.WriteLine("Deserialized Country data:");但是我现在得到了下面的错误。
类型'SalesNetData.Country‘不能序列化为JSON,因为它的IsReference设置是'True’。JSON格式不支持引用,因为没有表示引用的标准化格式。若要启用序列化,请禁用该类型的类型或适当的父类上的IsReference设置。
请帮忙..。
发布于 2009-10-30 14:45:55
有关此问题的解决方案,请参见下面的线程(community.codesmithtools.com/forums/p/10080/37441.aspx#37441)。您还应该了解一下牛顿Json.NET (codeplex.com/Json)的使用情况。
谢谢-Blake Niemyjski
发布于 2009-10-30 13:06:52
解决方案在错误信息中..。
若要启用序列化,请禁用类型
的类型或适当父类上的IsReference设置。
https://stackoverflow.com/questions/1646927
复制相似问题