I'm trying to serialize some objects with Web API in JSON-format. However, the JSON Serializer doesn't respect the settings in Global.asax and keeps nesting objects too deep. I am using Web API in combination with Entity Framework Code First.
This is the JSON-related code in Global.asax:
var jsonFormatter = GlobalConfiguration.Configuration.Formatters.JsonFormatter;
jsonFormatter.SerializerSettings.ReferenceLoopHandling
= Newtonsoft.Json.ReferenceLoopHandling.Ignore;
jsonFormatter.SerializerSettings.PreserveReferencesHandling
= Newtonsoft.Json.PreserveReferencesHandling.None;
I'm trying to get a list of Module-objects and this is the result: https://i.stack.imgur.com/yfh65.png
The content in the red shape is what I don't want to have serialized.
EDIT: Is it also possible to exclude specific properties and keep others?
Thanks in advance