在 C# 中反序列化 PLINQO 对象的问题
我尝试了很多方法来反序列化 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 设置。
请帮忙......
I have tried many ways to deserialize LINQO objects but every method failed. Here is an example of the last code.
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:");
But I get the following error now.
The type 'SalesNetData.Country' cannot be serialized to JSON because its IsReference setting is 'True'. The JSON format does not support references because there is no standardized format for representing references. To enable serialization, disable the IsReference setting on the type or an appropriate parent class of the type.
Please help.....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请参阅以下线程 (community.codesmithtools.com/forums/p/10080/37441.aspx#37441) 以获取此问题的解决方案。您还应该考虑使用 Newton Json.NET (codeplex.com/Json)。
谢谢
——布莱克·尼米斯基
Please see the following thread (community.codesmithtools.com/forums/p/10080/37441.aspx#37441) for a solution to this issue. You should also take a look into using Newton Json.NET (codeplex.com/Json).
Thanks
-Blake Niemyjski
解决方案在错误消息中...
The solution is in the error message...