A day with .Net

My day to day experince in .net

Posts Tagged ‘system text json case sensitive’

System Text Json Global Json options in ASPNET Core 5

Posted by vivekcek on December 7, 2020

In this post i will show you , How to configure Json options with System.Text.Json in Asp.net core 5. Here i configured ignoring casing in Json and String to enum mapping.

        public void ConfigureServices(IServiceCollection services)
        {
 
            services.AddControllers()
                .AddJsonOptions(options =>
                {
                    options.JsonSerializerOptions.PropertyNameCaseInsensitive = true;
                    options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter());
                });
           
        } 

Posted in ASP.NET Core | Tagged: , , , | Leave a Comment »