.net core 3 not having ReferenceLoopHandling in AddJsonOptions

As part of the work to improve the ASP.NET Core shared framework, Json.NET has been removed from the ASP.NET Core shared framework. Your app may require this reference if it uses Newtonsoft.Json-specific feature such as JsonPatch or converters or if it formats Newtonsoft.Json-specific types.

To use Json.NET in an ASP.NET Core 3.0 project:

Add a package reference to Microsoft.AspNetCore.Mvc.NewtonsoftJson.

Update Startup.ConfigureServices to call AddNewtonsoftJson.

services.AddMvc()
.AddNewtonsoftJson();

This sets up MVC and configures it to use Json.NET instead of that new API. And that AddNewtonsoftJson method has an overload that allows you to configure the Json.NET options like you were used to with AddJsonOptions in ASP.NET Core 2.x.

services.AddMvc()
.AddNewtonsoftJson(options =>
{
    options.SerializerSettings = new JsonSerializerSettings() { … };
});

Reference:

https://learn.microsoft.com/en-us/aspnet/core/migration/22-to-30?view=aspnetcore-2.2&tabs=visual-studio#jsonnet-support

https://stackoverflow.com/a/55666898/10201850

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)