I understand that ASP.NET Web API natively uses Json.NET for (de)serializing objects, but is there a way to specify a JsonSerializerSettings object that you want for it to use?
For example, what if I wanted to include type information into the serialized JSON string? Normally I’d inject settings into the .Serialize() call, but Web API does that silently. I can’t find a way to inject settings manually.
You can customize the
JsonSerializerSettingsby using theFormatters.JsonFormatter.SerializerSettingsproperty in theHttpConfigurationobject.For example, you could do that in the Application_Start() method: