AndreyAkinshin / knockout-mvc

Power of Knockout.js for ASP.NET MVC
http://knockoutmvc.com
203 stars 125 forks source link

KnockoutUtilities.ConvertData ignore JsonIgnore Attribute #29

Open diegohoyos opened 11 years ago

diegohoyos commented 11 years ago

I use JsonIgnore attribute to avoid circular references in Json serialization of entity framework classes. The problem is in KnockoutUtilities.ConvertData method because ignore this attribute when explore properties using reflection. This cause stack overflow exception when explore recursive circular references between entity framework objects.

diegohoyos commented 11 years ago

Please add the attribute validation. This avoid recursive exploration of objects that will not serialize by json.net, and avoid stack overflow exception caused by entity framework proxys with circular references.

if (property.GetCustomAttributes(typeof(Newtonsoft.Json.JsonIgnoreAttribute), false).Length > 0) continue;