ASP.NET Core disable json patch

Viewed 271

As stated in this article: adding NewtonsoftJson to the application now enables json patch support. I'm wondering how to add NewthonsoftJson without enabling json patch?

1 Answers

JsonPatch support is handled through the NewtonsoftJsonPatchInputFormatter type. If you don't want this to be enabled, remove it from the InputFormatters collection. Here's an example:

services.AddControllers()
    .AddNewtonsoftJson()
    .AddMvcOptions(o => o.InputFormatters.RemoveType<NewtonsoftJsonPatchInputFormatter>());
Related