Skip to content

Instantly share code, notes, and snippets.

@dariusz-wozniak
Forked from regisdiogo/Startup.cs
Created August 2, 2019 09:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dariusz-wozniak/6c1a00b132e9193c753eb1dfa71a4415 to your computer and use it in GitHub Desktop.
Save dariusz-wozniak/6c1a00b132e9193c753eb1dfa71a4415 to your computer and use it in GitHub Desktop.
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;
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment