ASP.NET Core MVC features that use Newtonsoft.Json. Includes input and output formatters for JSON and JSON PATCH. This package was built from the source code at https://github.com/dotnet/dotnet/tree/87bc0b04e21d786669142109a5128c95618b75ed
$ dotnet add package Microsoft.AspNetCore.Mvc.NewtonsoftJsonMicrosoft.AspNetCore.Mvc.NewtonsoftJson is a NuGet package designed to enable the use of JSON serialization and deserialization using Newtonsoft.Json in ASP.NET Core MVC applications. This package provides support for handling JSON input and output in ASP.NET Core MVC controllers, allowing for seamless integration with existing Newtonsoft.Json configurations and features.
To start using Microsoft.AspNetCore.Mvc.NewtonsoftJson in your ASP.NET Core MVC application, follow these steps:
dotnet add package Microsoft.AspNetCore.Mvc.NewtonsoftJson
In your Startup.cs file, configure NewtonsoftJson as the default JSON serializer for ASP.NET Core MVC:
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json;
public void ConfigureServices(IServiceCollection services)
{
services.AddControllersWithViews()
.AddNewtonsoftJson(options =>
{
// Configure Newtonsoft.Json options here
options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
});
}
Now, you can use Newtonsoft.Json serialization and deserialization in your ASP.NET Core MVC controllers:
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
public class SampleController : Controller
{
[HttpPost]
public IActionResult Post([FromBody] MyModel model)
{
// Your action logic here
}
}
public class MyModel
{
public string Name { get; set; }
public int Age { get; set; }
}
<!-- The main types provided in this library -->
<!-- Links to further documentation. Remove conceptual documentation if not available for the library. -->
<!-- How to provide feedback on this package and contribute to it -->
For more information on configuring and using Newtonsoft.Json in ASP.NET Core MVC, refer to the official documentation.
The main types provided by this library are:
NewtonsoftJsonOptions: Options for configuring Newtonsoft.Json serialization settings.NewtonsoftJsonInputFormatter: Input formatter for handling JSON input using Newtonsoft.Json.NewtonsoftJsonOutputFormatter: Output formatter for handling JSON output using Newtonsoft.Json.Microsoft.AspNetCore.Authentication.JwtBearer is released as open-source under the MIT license. Bug reports and contributions are welcome at the GitHub repository.