Adding Newtonsoft JSON back to .NET Core 3.1 and Later
●
Permalink
●
suggest edit
When developing .NET Core 3.1 applications or later, you may notice that Microsoft has changed to use the default dependency to System.Text.Json
. The new serializer is very lightweight, but is still maturing. So, you may find that you need to add Newtonsoft JSON back in. To do this, we’ll first need to add a reference to the package by either running:
1
Install-Package Microsoft.AspNetCore.Mvc.NewtonsoftJson
or
1
dotnet add package Microsoft.AspNetCore.Mvc.NewtonsoftJson
Then, update the ConfigureServices
method by adding AddNewtonsoftJson()
to AddControllers()
like so: