PedroWilliam
9/27/2016 - 1:15 PM

ASP.NET Core - Json serializer settings Enum as string and ignore null values

ASP.NET Core - Json serializer settings Enum as string and ignore null values

public class Startup
{
  public IServiceProvider ConfigureServices(IServiceCollection services)
  {
    services.AddMvc().AddJsonOptions(options =>
    {
      options.SerializerSettings.Converters.Add(new Newtonsoft.Json.Converters.StringEnumConverter());
      options.SerializerSettings.NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore;
    });
  }
}