Serialization of default values Web Api and Json.NET

If you're using ASP.NET Web Api and some properties isn't serialized when serializing to json if the value is default value. An example is when bool properties with false as value not are serialized try to add the following code in the Register method of the WebApiConfig class.

config.Formatters.JsonFormatter.SerializerSettings.DefaultValueHandling =
                                   Newtonsoft.Json.DefaultValueHandling.Include;

  3/2/2015 - 2:09 PM