内容简介:代码日志版权声明:翻译自:http://stackoverflow.com/questions/2954050/jsonignore-attributes-not-working-in-asp-net
我的项目中有一个对象在循环引用.我已经把[JsonIgnore]放在这个领域之上了:
[JsonIgnore]
public virtual Foobar ChildObject { get; set; }
当我序列化对象时,我仍然收到循环引用错误.没有JsonIgnore的唯一字段是字符串字段,不应该是这样的.还有什么我需要做的让JsonIgnore工作吗?
谢谢!
您可能有一些其他属性链接到其父级.使用ReferenceLoopHandling.Ignore设置来防止自引用循环.
using Newtonsoft.Json; JsonSerializerSettings jsSettings = new JsonSerializerSettings(); jsSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; string json = JsonConvert.SerializeObject(foobars, Formatting.None, jsSettings);
代码日志版权声明:
翻译自:http://stackoverflow.com/questions/2954050/jsonignore-attributes-not-working-in-asp-net
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Distributed Algorithms: An Intuitive Approach
Wan Fokkink / MIT Press / 2018-2-2 / USD 48.00
The new edition of a guide to distributed algorithms that emphasizes examples and exercises rather than the intricacies of mathematical models. This book offers students and researchers a guide to ......一起来看看 《Distributed Algorithms: An Intuitive Approach》 这本书的介绍吧!