Microsoft.AspNetCore.JsonPatch 10.0.0-preview.3.25172.1
About
Microsoft.AspNetCore.JsonPatch
provides ASP.NET Core support for JSON PATCH requests.
How to Use
To use Microsoft.AspNetCore.JsonPatch
, follow these steps:
Installation
dotnet add package Microsoft.AspNetCore.JsonPatch
dotnet add package Microsoft.AspNetCore.Mvc.NewtonsoftJson
Configuration
To enable JSON Patch support, call AddNewtonsoftJson
in your ASP.NET Core app's Program.cs
:
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers()
.AddNewtonsoftJson();
Configure when using System.Text.Json
To add support for JSON Patch using Newtonsoft.Json
while continuing to use System.Text.Json
for other input and output formatters:
- Update your
Program.cs
with logic to construct aNewtonsoftJsonPatchInputFormatter
:static NewtonsoftJsonPatchInputFormatter GetJsonPatchInputFormatter() { var builder = new ServiceCollection() .AddLogging() .AddMvc() .AddNewtonsoftJson() .Services.BuildServiceProvider(); return builder .GetRequiredService<IOptions<MvcOptions>>() .Value .InputFormatters .OfType<NewtonsoftJsonPatchInputFormatter>() .First(); }
- Configure the input formatter:
var builder = WebApplication.CreateBuilder(args); builder.Services.AddControllers(options => { options.InputFormatters.Insert(0, GetJsonPatchInputFormatter()); });
Usage
To define an action method for a JSON Patch in an API controller:
- Annotate it with the
HttpPatch
attribute - Accept a
JsonPatchDocument<TModel>
- Call
ApplyTo
on the patch document to apply changes
For example:
[HttpPatch]
public IActionResult JsonPatchWithModelState(
[FromBody] JsonPatchDocument<Customer> patchDoc)
{
if (patchDoc is not null)
{
var customer = CreateCustomer();
patchDoc.ApplyTo(customer, ModelState);
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
return new ObjectResult(customer);
}
else
{
return BadRequest(ModelState);
}
}
In a real app, the code would retrieve the data from a store such as a database and update the database after applying the patch.
Additional Documentation
For additional documentation and examples, refer to the official documentation on JSON Patch in ASP.NET Core.
Feedback & Contributing
Microsoft.AspNetCore.JsonPatch
is released as open-source under the MIT license. Bug reports and contributions are welcome at the GitHub repository.
Showing the top 20 packages that depend on Microsoft.AspNetCore.JsonPatch.
Packages | Downloads |
---|---|
KubernetesClient
Client library for the Kubernetes open source container orchestrator.
|
18 |
KubernetesClient
Client library for the Kubernetes open source container orchestrator.
|
19 |
KubernetesClient
Client library for the Kubernetes open source container orchestrator.
|
20 |
KubernetesClient
Client library for the Kubernetes open source container orchestrator.
|
21 |
KubernetesClient
Client library for the Kubernetes open source container orchestrator.
|
26 |
Microsoft.AspNetCore.Mvc.Formatters.Json
ASP.NET Core MVC formatters for JSON input and output and for JSON PATCH input using Json.NET.
This package was built from the source at:
https://github.com/aspnet/Mvc/tree/fb57810f2960730e59db0235207b873c924bc3fd
|
19 |
Microsoft.AspNetCore.Mvc.NewtonsoftJson
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/aspnetcore/tree/02c6de4ba6022025fcda7581415f310f8c73cdc3
|
19 |
Microsoft.AspNetCore.Mvc.NewtonsoftJson
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/aspnetcore/tree/06b2bc111203f9b9ff0914a7715675a9a66bdac9
|
19 |
Microsoft.AspNetCore.Mvc.NewtonsoftJson
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/aspnetcore/tree/0a715692d8e2536c899faa0bb4f0cec2c2e33e36
|
22 |
Microsoft.AspNetCore.Mvc.NewtonsoftJson
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/aspnetcore/tree/2aa401550574f93402eba13ff9a4827ef01a2f3a
|
20 |
Microsoft.AspNetCore.Mvc.NewtonsoftJson
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/aspnetcore/tree/39e0501ee91dcf2b9b885d647795184815fb0408
|
18 |
Microsoft.AspNetCore.Mvc.NewtonsoftJson
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/aspnetcore/tree/3eeb12e106b9e913c3a4dec1a7d16da7b74149eb
|
9,335 |
Microsoft.AspNetCore.Mvc.NewtonsoftJson
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/aspnetcore/tree/3f1acb59718cadf111a0a796681e3d3509bb3381
|
363 |
Microsoft.AspNetCore.Mvc.NewtonsoftJson
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/aspnetcore/tree/47576478939fdd59b4400ad135f47938af486ab3
|
25 |
Microsoft.AspNetCore.Mvc.NewtonsoftJson
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/aspnetcore/tree/54142bcb25544b72fac28b1b061e7788c91c4f49
|
22 |
Microsoft.AspNetCore.Mvc.NewtonsoftJson
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/aspnetcore/tree/617d594f2bf75a8904d3d0e7d68a0bacf8e6763a
|
20 |
Microsoft.AspNetCore.Mvc.NewtonsoftJson
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/aspnetcore/tree/bb01bbf4433e27289b99001b7de6a582879d1835
|
19 |
Microsoft.AspNetCore.Mvc.NewtonsoftJson
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/aspnetcore/tree/bc25dd5d39fd057f7cb28acb5ad4d9e925a375de
|
19 |
Microsoft.AspNetCore.Mvc.NewtonsoftJson
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/aspnetcore/tree/fb4b5a21ebd67b31fff4ddf5c039181da504c932
|
36 |
.NET Framework 4.6.2
- Microsoft.CSharp (>= 4.7.0)
- Newtonsoft.Json (>= 13.0.3)
.NET 10.0
- Newtonsoft.Json (>= 13.0.3)
.NET Standard 2.0
- Microsoft.CSharp (>= 4.7.0)
- Newtonsoft.Json (>= 13.0.3)
Version | Downloads | Last updated |
---|---|---|
10.0.0-preview.3.25172.1 | 3 | 04/17/2025 |
10.0.0-preview.2.25164.1 | 7 | 03/30/2025 |
10.0.0-preview.1.25120.3 | 9 | 02/27/2025 |
9.0.4 | 0 | 04/08/2025 |
9.0.3 | 7 | 03/17/2025 |
9.0.2 | 8 | 02/27/2025 |
9.0.1 | 10 | 01/21/2025 |
9.0.0 | 14 | 11/14/2024 |
9.0.0-rc.2.24474.3 | 10 | 11/15/2024 |
9.0.0-rc.1.24452.1 | 12 | 11/14/2024 |
9.0.0-preview.7.24406.2 | 9 | 12/01/2024 |
9.0.0-preview.6.24328.4 | 12 | 12/11/2024 |
9.0.0-preview.5.24306.11 | 11 | 11/16/2024 |
9.0.0-preview.4.24267.6 | 13 | 05/26/2024 |
9.0.0-preview.3.24172.13 | 12 | 05/26/2024 |
9.0.0-preview.2.24128.4 | 16 | 05/26/2024 |
9.0.0-preview.1.24081.5 | 13 | 05/26/2024 |
8.0.15 | 0 | 04/08/2025 |
8.0.14 | 8 | 03/17/2025 |
8.0.13 | 9 | 02/18/2025 |
8.0.12 | 11 | 01/24/2025 |
8.0.11 | 18 | 11/14/2024 |
8.0.10 | 10 | 11/16/2024 |
8.0.8 | 10 | 11/17/2024 |
8.0.7 | 12 | 11/16/2024 |
8.0.6 | 11 | 11/16/2024 |
8.0.5 | 15 | 05/26/2024 |
8.0.4 | 12 | 05/26/2024 |
8.0.3 | 15 | 05/26/2024 |
8.0.2 | 14 | 05/26/2024 |
8.0.1 | 14 | 02/04/2024 |
8.0.0 | 228 | 12/18/2023 |
8.0.0-rc.2.23480.2 | 10 | 05/26/2024 |
8.0.0-rc.1.23421.29 | 14 | 05/26/2024 |
8.0.0-preview.7.23375.9 | 15 | 05/26/2024 |
8.0.0-preview.6.23329.11 | 32 | 08/08/2023 |
8.0.0-preview.5.23302.2 | 13 | 05/26/2024 |
8.0.0-preview.4.23260.4 | 13 | 05/26/2024 |
8.0.0-preview.3.23177.8 | 12 | 05/26/2024 |
8.0.0-preview.2.23153.2 | 11 | 05/26/2024 |
8.0.0-preview.1.23112.2 | 10 | 05/26/2024 |
7.0.20 | 11 | 11/16/2024 |
7.0.19 | 18 | 05/26/2024 |
7.0.18 | 14 | 05/26/2024 |
7.0.17 | 16 | 05/26/2024 |
7.0.16 | 17 | 05/26/2024 |
7.0.15 | 18 | 05/01/2024 |
7.0.14 | 15 | 02/04/2024 |
7.0.13 | 12 | 05/26/2024 |
7.0.12 | 17 | 05/26/2024 |
7.0.11 | 14 | 05/26/2024 |
7.0.10 | 16 | 05/26/2024 |
7.0.9 | 16 | 05/26/2024 |
7.0.8 | 12 | 05/26/2024 |
7.0.7 | 17 | 05/26/2024 |
7.0.5 | 16 | 06/16/2023 |
7.0.4 | 13 | 05/26/2024 |
7.0.3 | 15 | 07/13/2023 |
7.0.2 | 13 | 05/26/2024 |
7.0.1 | 16 | 05/26/2024 |
7.0.0 | 19 | 05/26/2024 |
7.0.0-rc.2.22476.2 | 17 | 05/26/2024 |
7.0.0-rc.1.22427.2 | 12 | 05/26/2024 |
7.0.0-preview.7.22376.6 | 15 | 05/26/2024 |
7.0.0-preview.6.22330.3 | 14 | 05/26/2024 |
7.0.0-preview.5.22303.8 | 13 | 05/26/2024 |
7.0.0-preview.4.22251.1 | 13 | 05/26/2024 |
7.0.0-preview.2.22153.2 | 15 | 05/26/2024 |
6.0.36 | 12 | 11/19/2024 |
6.0.35 | 11 | 11/17/2024 |
6.0.33 | 10 | 11/17/2024 |
6.0.32 | 11 | 11/17/2024 |
6.0.31 | 11 | 11/17/2024 |
6.0.30 | 17 | 05/26/2024 |
6.0.29 | 18 | 05/26/2024 |
6.0.28 | 17 | 05/26/2024 |
6.0.27 | 12 | 05/26/2024 |
6.0.26 | 15 | 05/26/2024 |
6.0.25 | 16 | 05/26/2024 |
6.0.24 | 17 | 05/26/2024 |
6.0.23 | 16 | 05/26/2024 |
6.0.22 | 15 | 05/26/2024 |
6.0.21 | 14 | 05/26/2024 |
6.0.20 | 15 | 05/26/2024 |
6.0.19 | 16 | 05/26/2024 |
6.0.18 | 16 | 05/26/2024 |
6.0.16 | 14 | 05/26/2024 |
6.0.15 | 16 | 05/26/2024 |
6.0.14 | 15 | 05/26/2024 |
6.0.13 | 16 | 05/26/2024 |
6.0.12 | 14 | 05/26/2024 |
6.0.11 | 16 | 05/26/2024 |
6.0.10 | 15 | 05/26/2024 |
6.0.9 | 17 | 05/03/2024 |
6.0.7 | 15 | 05/26/2024 |
6.0.6 | 12 | 05/26/2024 |
6.0.5 | 17 | 10/28/2022 |
6.0.0-rc.2.21480.10 | 11 | 05/26/2024 |
6.0.0-rc.1.21452.15 | 14 | 11/03/2022 |
6.0.0-preview.7.21378.6 | 14 | 05/26/2024 |
6.0.0-preview.4.21253.5 | 14 | 05/26/2024 |
6.0.0-preview.3.21201.13 | 15 | 05/26/2024 |
6.0.0-preview.2.21154.6 | 15 | 05/26/2024 |
6.0.0-preview.1.21103.6 | 13 | 05/26/2024 |
5.0.17 | 18 | 07/13/2023 |
5.0.9 | 16 | 05/26/2024 |
5.0.8 | 17 | 05/26/2024 |
5.0.6 | 15 | 05/26/2024 |
5.0.5 | 15 | 05/26/2024 |
5.0.3 | 16 | 05/26/2024 |
5.0.2 | 17 | 05/26/2024 |
5.0.0 | 15 | 05/26/2024 |
5.0.0-rc.1.20451.17 | 17 | 05/26/2024 |
5.0.0-preview.8.20414.8 | 10 | 05/26/2024 |
5.0.0-preview.7.20365.19 | 16 | 05/26/2024 |
5.0.0-preview.6.20312.15 | 14 | 05/26/2024 |
5.0.0-preview.4.20257.10 | 16 | 05/26/2024 |
5.0.0-preview.3.20215.14 | 13 | 05/26/2024 |
3.1.32 | 9,067 | 05/11/2023 |
3.1.31 | 12 | 05/26/2024 |
3.1.29 | 14 | 05/26/2024 |
3.1.28 | 17 | 05/26/2024 |
3.1.27 | 14 | 05/26/2024 |
3.1.26 | 15 | 05/26/2024 |
3.1.25 | 12 | 05/26/2024 |
3.1.23 | 15 | 04/30/2024 |
3.1.19 | 15 | 05/26/2024 |
3.1.18 | 14 | 05/26/2024 |
3.1.8 | 15 | 05/26/2024 |
3.1.6 | 13 | 05/26/2024 |
3.1.1 | 13 | 05/26/2024 |
3.1.0-preview2.19528.8 | 14 | 05/26/2024 |
3.0.0-rc1.19457.4 | 13 | 05/26/2024 |
3.0.0-preview9.19424.4 | 13 | 05/26/2024 |
3.0.0-preview8.19405.7 | 14 | 05/26/2024 |
3.0.0-preview6.19307.2 | 15 | 05/26/2024 |
3.0.0-preview5-19227-01 | 12 | 05/26/2024 |
3.0.0-preview4-19216-03 | 16 | 05/26/2024 |
3.0.0-preview3-19153-02 | 16 | 05/26/2024 |
3.0.0-preview-19075-0444 | 15 | 05/26/2024 |
3.0.0-preview-18579-0056 | 17 | 05/26/2024 |
2.3.0 | 9 | 01/20/2025 |
2.2.0 | 28 | 09/08/2023 |
2.2.0-preview3-35497 | 16 | 05/26/2024 |
2.2.0-preview1-35029 | 14 | 05/26/2024 |
2.1.0 | 14 | 05/26/2024 |
2.1.0-preview1-final | 13 | 05/26/2024 |
2.0.0 | 16 | 06/06/2023 |
2.0.0-preview2-final | 17 | 05/26/2024 |
2.0.0-preview1-final | 16 | 05/26/2024 |
1.1.2 | 15 | 05/26/2024 |
1.1.0-preview1-final | 14 | 05/26/2024 |
1.0.0-rc2-final | 15 | 05/26/2024 |