我有一个POCO类,它以JSON字符串的形式发送到浏览器中.NET3.5SP1.我只是在使用默认的JSON序列化,我想忽略一些字段.我想在它们上添加一个类似于[System.Xml.Serialization.XmlIgnore]的属性,这样它们就不会被序列化.
我有一个POCO类,它以JSON字符串的形式发送到浏览器中.NET3.5SP1.我只是在使用默认的JSON序列化,我想忽略一些字段.我想在它们上添加一个类似于[System.Xml.Serialization.XmlIgnore]的属性,这样它们就不会被序列化.
I use the ScriptIgnore attribute on my model like so:
public class Item
{
[ScriptIgnore]
public Item ParentItem { get; set; }
}
In this particular scenario I was getting a circular reference error from the Json serializer, so I simply ignored it. I was asking a similar question here on SO when I was turned on to the difference between a Model and ViewModel.