Microsoft.AspNetCore.JsonPatch 10.0.2
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.cswith 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
HttpPatchattribute - Accept a
JsonPatchDocument<TModel> - Call
ApplyToon 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 |
|---|---|
|
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 code at https://github.com/aspnet/Mvc/tree/a6199bbfbab05583f987bae322fb04566841aaea
|
167 |
|
Microsoft.AspNetCore.Mvc.Formatters.Json
ASP.NET Core MVC formatters for JSON input and output and for JSON PATCH input using Json.NET.
|
158 |
|
Microsoft.AspNetCore.Mvc.Formatters.Json
ASP.NET Core MVC formatters for JSON input and output and for JSON PATCH input using Json.NET.
|
147 |
|
Microsoft.AspNetCore.Mvc.Formatters.Json
ASP.NET Core MVC formatters for JSON input and output and for JSON PATCH input using Json.NET.
|
145 |
|
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/b9793f0a1d9a75940c50e31e956d09397a5d1876
|
145 |
|
Microsoft.AspNetCore.Mvc.Formatters.Json
ASP.NET Core MVC formatters for JSON input and output and for JSON PATCH input using Json.NET.
|
144 |
|
Microsoft.AspNetCore.Mvc.Formatters.Json
ASP.NET Core MVC formatters for JSON input and output and for JSON PATCH input using Json.NET.
|
143 |
|
Microsoft.AspNetCore.Mvc.Formatters.Json
ASP.NET Core MVC formatters for JSON input and output and for JSON PATCH input using Json.NET.
|
142 |
|
Microsoft.AspNetCore.Mvc.Formatters.Json
ASP.NET Core MVC formatters for JSON input and output and for JSON PATCH input using Json.NET.
|
141 |
|
Microsoft.AspNetCore.Mvc.Formatters.Json
ASP.NET Core MVC formatters for JSON input and output and for JSON PATCH input using Json.NET.
|
139 |
|
Microsoft.AspNetCore.Mvc.Formatters.Json
ASP.NET Core MVC formatters for JSON input and output and for JSON PATCH input using Json.NET.
|
138 |
|
Microsoft.AspNetCore.Mvc.Formatters.Json
ASP.NET Core MVC formatters for JSON input and output and for JSON PATCH input using Json.NET.
|
137 |
|
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/522006d2c866add522a546aa3b4720577f1cee57
|
137 |
|
Microsoft.AspNetCore.Mvc.Formatters.Json
ASP.NET Core MVC formatters for JSON input and output and for JSON PATCH input using Json.NET.
|
136 |
|
Microsoft.AspNetCore.Mvc.Formatters.Json
ASP.NET Core MVC formatters for JSON input and output and for JSON PATCH input using Json.NET.
|
135 |
|
Microsoft.AspNetCore.Mvc.Formatters.Json
ASP.NET Core MVC formatters for JSON input and output and for JSON PATCH input using Json.NET.
|
134 |
|
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
|
133 |
|
Microsoft.AspNetCore.Mvc.Formatters.Json
ASP.NET Core MVC formatters for JSON input and output and for JSON PATCH input using Json.NET.
|
133 |
.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 |
|---|---|---|
| 11.0.0-preview.2.26159.112 | 3 | 3/12/2026 |
| 11.0.0-preview.1.26104.118 | 6 | 2/12/2026 |
| 10.0.5 | 2 | 3/14/2026 |
| 10.0.4 | 3 | 3/12/2026 |
| 10.0.3 | 5 | 2/12/2026 |
| 10.0.2 | 9 | 1/21/2026 |
| 10.0.1 | 22 | 12/10/2025 |
| 10.0.0 | 39 | 11/11/2025 |
| 10.0.0-rc.2.25502.107 | 55 | 10/14/2025 |
| 10.0.0-rc.1.25451.107 | 60 | 9/10/2025 |
| 10.0.0-preview.7.25380.108 | 64 | 8/13/2025 |
| 10.0.0-preview.6.25358.103 | 56 | 7/16/2025 |
| 10.0.0-preview.5.25277.114 | 79 | 6/8/2025 |
| 10.0.0-preview.4.25258.110 | 60 | 5/14/2025 |
| 10.0.0-preview.3.25172.1 | 70 | 4/14/2025 |
| 10.0.0-preview.2.25164.1 | 91 | 3/22/2025 |
| 10.0.0-preview.1.25120.3 | 95 | 2/27/2025 |
| 9.0.14 | 3 | 3/12/2026 |
| 9.0.13 | 5 | 2/12/2026 |
| 9.0.12 | 9 | 1/20/2026 |
| 9.0.11 | 35 | 11/11/2025 |
| 9.0.10 | 62 | 10/15/2025 |
| 9.0.9 | 58 | 9/10/2025 |
| 9.0.8 | 61 | 8/5/2025 |
| 9.0.7 | 59 | 7/11/2025 |
| 9.0.6 | 63 | 6/14/2025 |
| 9.0.5 | 68 | 5/14/2025 |
| 9.0.4 | 78 | 4/11/2025 |
| 9.0.3 | 86 | 3/15/2025 |
| 9.0.2 | 76 | 2/14/2025 |
| 9.0.1 | 96 | 1/19/2025 |
| 9.0.0 | 86 | 11/13/2024 |
| 9.0.0-rc.2.24474.3 | 84 | 10/8/2024 |
| 9.0.0-rc.1.24452.1 | 88 | 9/12/2024 |
| 9.0.0-preview.7.24406.2 | 109 | 8/13/2024 |
| 9.0.0-preview.6.24328.4 | 91 | 7/10/2024 |
| 9.0.0-preview.5.24306.11 | 91 | 6/15/2024 |
| 9.0.0-preview.4.24267.6 | 89 | 5/24/2024 |
| 9.0.0-preview.3.24172.13 | 101 | 4/16/2024 |
| 9.0.0-preview.2.24128.4 | 101 | 3/14/2024 |
| 9.0.0-preview.1.24081.5 | 100 | 2/20/2024 |
| 8.0.25 | 3 | 3/12/2026 |
| 8.0.24 | 7 | 2/12/2026 |
| 8.0.23 | 11 | 1/21/2026 |
| 8.0.22 | 44 | 11/11/2025 |
| 8.0.21 | 49 | 10/15/2025 |
| 8.0.20 | 71 | 9/10/2025 |
| 8.0.19 | 58 | 8/5/2025 |
| 8.0.18 | 57 | 7/11/2025 |
| 8.0.17 | 58 | 6/14/2025 |
| 8.0.16 | 77 | 5/14/2025 |
| 8.0.15 | 78 | 4/11/2025 |
| 8.0.14 | 70 | 3/15/2025 |
| 8.0.13 | 81 | 2/14/2025 |
| 8.0.12 | 84 | 1/19/2025 |
| 8.0.11 | 92 | 11/13/2024 |
| 8.0.10 | 82 | 10/8/2024 |
| 8.0.8 | 93 | 8/13/2024 |
| 8.0.7 | 112 | 7/9/2024 |
| 8.0.6 | 99 | 5/29/2024 |
| 8.0.5 | 96 | 5/17/2024 |
| 8.0.4 | 92 | 4/14/2024 |
| 8.0.3 | 91 | 3/12/2024 |
| 8.0.2 | 99 | 2/19/2024 |
| 8.0.1 | 100 | 2/3/2024 |
| 8.0.0 | 93 | 11/15/2023 |
| 8.0.0-rc.2.23480.2 | 119 | 10/12/2023 |
| 8.0.0-rc.1.23421.29 | 120 | 9/15/2023 |
| 8.0.0-preview.7.23375.9 | 105 | 8/22/2023 |
| 8.0.0-preview.6.23329.11 | 114 | 7/30/2023 |
| 8.0.0-preview.5.23302.2 | 124 | 7/26/2023 |
| 8.0.0-preview.4.23260.4 | 134 | 7/31/2023 |
| 8.0.0-preview.3.23177.8 | 120 | 5/14/2023 |
| 8.0.0-preview.2.23153.2 | 121 | 4/11/2023 |
| 8.0.0-preview.1.23112.2 | 118 | 2/25/2023 |
| 7.0.20 | 103 | 5/29/2024 |
| 7.0.19 | 97 | 5/17/2024 |
| 7.0.18 | 89 | 4/14/2024 |
| 7.0.17 | 99 | 3/12/2024 |
| 7.0.16 | 106 | 2/21/2024 |
| 7.0.15 | 94 | 1/23/2024 |
| 7.0.14 | 103 | 11/15/2023 |
| 7.0.13 | 109 | 10/30/2023 |
| 7.0.12 | 101 | 10/10/2023 |
| 7.0.11 | 107 | 9/16/2023 |
| 7.0.10 | 107 | 8/22/2023 |
| 7.0.9 | 97 | 7/31/2023 |
| 7.0.8 | 99 | 7/12/2023 |
| 7.0.7 | 109 | 7/16/2023 |
| 7.0.5 | 106 | 7/31/2023 |
| 7.0.4 | 94 | 7/31/2023 |
| 7.0.3 | 102 | 2/21/2023 |
| 7.0.2 | 110 | 1/27/2023 |
| 7.0.1 | 113 | 2/23/2023 |
| 7.0.0 | 115 | 12/4/2022 |
| 7.0.0-rc.2.22476.2 | 124 | 11/4/2022 |
| 7.0.0-rc.1.22427.2 | 116 | 9/25/2022 |
| 7.0.0-preview.7.22376.6 | 108 | 10/25/2022 |
| 7.0.0-preview.6.22330.3 | 101 | 11/27/2022 |
| 7.0.0-preview.5.22303.8 | 129 | 6/27/2022 |
| 7.0.0-preview.4.22251.1 | 110 | 6/28/2022 |
| 7.0.0-preview.3.22178.4 | 118 | 3/9/2023 |
| 7.0.0-preview.2.22153.2 | 94 | 9/17/2022 |
| 7.0.0-preview.1.22109.13 | 123 | 11/4/2022 |
| 6.0.36 | 96 | 11/13/2024 |
| 6.0.35 | 83 | 10/8/2024 |
| 6.0.33 | 87 | 8/13/2024 |
| 6.0.32 | 100 | 7/9/2024 |
| 6.0.31 | 102 | 5/29/2024 |
| 6.0.30 | 108 | 5/17/2024 |
| 6.0.29 | 97 | 4/14/2024 |
| 6.0.28 | 108 | 3/12/2024 |
| 6.0.27 | 105 | 2/19/2024 |
| 6.0.26 | 101 | 1/28/2024 |
| 6.0.25 | 107 | 11/15/2023 |
| 6.0.24 | 109 | 10/30/2023 |
| 6.0.23 | 114 | 10/10/2023 |
| 6.0.22 | 114 | 9/16/2023 |
| 6.0.21 | 102 | 8/22/2023 |
| 6.0.20 | 126 | 7/20/2023 |
| 6.0.19 | 113 | 7/31/2023 |
| 6.0.18 | 97 | 7/31/2023 |
| 6.0.16 | 111 | 5/13/2023 |
| 6.0.15 | 98 | 4/5/2023 |
| 6.0.14 | 116 | 2/23/2023 |
| 6.0.13 | 105 | 2/23/2023 |
| 6.0.12 | 112 | 2/23/2023 |
| 6.0.11 | 105 | 11/24/2022 |
| 6.0.10 | 110 | 12/4/2022 |
| 6.0.9 | 96 | 5/13/2023 |
| 6.0.8 | 107 | 12/25/2022 |
| 6.0.7 | 129 | 12/22/2022 |
| 6.0.6 | 125 | 6/29/2022 |
| 6.0.5 | 104 | 11/30/2022 |
| 6.0.4 | 120 | 1/5/2023 |
| 6.0.3 | 105 | 11/4/2022 |
| 6.0.2 | 107 | 11/5/2022 |
| 6.0.1 | 115 | 10/14/2022 |
| 6.0.0 | 136 | 7/10/2022 |
| 6.0.0-rc.2.21480.10 | 113 | 1/14/2023 |
| 6.0.0-rc.1.21452.15 | 140 | 12/24/2022 |
| 6.0.0-preview.7.21378.6 | 108 | 6/29/2022 |
| 6.0.0-preview.6.21355.2 | 123 | 2/28/2023 |
| 6.0.0-preview.5.21301.17 | 118 | 11/7/2022 |
| 6.0.0-preview.4.21253.5 | 112 | 10/26/2022 |
| 6.0.0-preview.3.21201.13 | 115 | 6/28/2022 |
| 6.0.0-preview.2.21154.6 | 106 | 9/21/2022 |
| 6.0.0-preview.1.21103.6 | 103 | 9/22/2022 |
| 5.0.17 | 114 | 9/2/2022 |
| 5.0.16 | 103 | 12/21/2022 |
| 5.0.15 | 124 | 8/10/2022 |
| 5.0.14 | 96 | 1/20/2023 |
| 5.0.13 | 97 | 10/21/2022 |
| 5.0.12 | 108 | 5/13/2023 |
| 5.0.11 | 120 | 9/19/2022 |
| 5.0.10 | 97 | 11/30/2022 |
| 5.0.9 | 124 | 1/22/2023 |
| 5.0.8 | 106 | 5/13/2023 |
| 5.0.7 | 118 | 9/21/2022 |
| 5.0.6 | 104 | 9/13/2022 |
| 5.0.5 | 127 | 12/15/2022 |
| 5.0.4 | 111 | 10/3/2022 |
| 5.0.3 | 133 | 10/3/2022 |
| 5.0.2 | 125 | 12/30/2022 |
| 5.0.1 | 110 | 2/21/2023 |
| 5.0.0 | 120 | 2/2/2023 |
| 5.0.0-rc.2.20475.17 | 114 | 10/16/2022 |
| 5.0.0-rc.1.20451.17 | 137 | 10/22/2022 |
| 5.0.0-preview.8.20414.8 | 109 | 10/19/2022 |
| 5.0.0-preview.7.20365.19 | 119 | 2/28/2023 |
| 5.0.0-preview.6.20312.15 | 118 | 8/18/2022 |
| 5.0.0-preview.5.20279.2 | 108 | 3/24/2023 |
| 5.0.0-preview.4.20257.10 | 126 | 10/10/2022 |
| 5.0.0-preview.3.20215.14 | 125 | 11/24/2022 |
| 5.0.0-preview.2.20167.3 | 122 | 10/14/2022 |
| 5.0.0-preview.1.20124.5 | 110 | 4/9/2023 |
| 3.1.32 | 126 | 2/23/2023 |
| 3.1.31 | 108 | 12/4/2022 |
| 3.1.30 | 116 | 12/4/2022 |
| 3.1.29 | 108 | 5/13/2023 |
| 3.1.28 | 128 | 9/8/2022 |
| 3.1.27 | 112 | 11/14/2022 |
| 3.1.26 | 97 | 5/17/2023 |
| 3.1.25 | 136 | 8/25/2022 |
| 3.1.24 | 109 | 6/27/2022 |
| 3.1.23 | 106 | 10/6/2022 |
| 3.1.22 | 111 | 11/7/2022 |
| 3.1.21 | 119 | 6/28/2022 |
| 3.1.20 | 100 | 5/17/2023 |
| 3.1.19 | 131 | 9/5/2022 |
| 3.1.18 | 102 | 2/7/2023 |
| 3.1.17 | 112 | 8/29/2022 |
| 3.1.16 | 109 | 9/26/2022 |
| 3.1.15 | 102 | 12/18/2022 |
| 3.1.14 | 104 | 9/26/2022 |
| 3.1.13 | 98 | 9/3/2022 |
| 3.1.12 | 111 | 6/30/2022 |
| 3.1.11 | 122 | 2/11/2023 |
| 3.1.10 | 129 | 10/15/2022 |
| 3.1.9 | 111 | 6/29/2022 |
| 3.1.8 | 99 | 9/20/2022 |
| 3.1.7 | 113 | 5/13/2023 |
| 3.1.6 | 106 | 8/9/2022 |
| 3.1.5 | 107 | 12/21/2022 |
| 3.1.4 | 116 | 6/30/2022 |
| 3.1.3 | 88 | 9/18/2022 |
| 3.1.2 | 103 | 9/5/2022 |
| 3.1.1 | 100 | 12/2/2022 |
| 3.1.0 | 118 | 9/26/2022 |
| 3.1.0-preview3.19555.2 | 125 | 3/2/2023 |
| 3.1.0-preview2.19528.8 | 116 | 9/13/2022 |
| 3.1.0-preview1.19508.20 | 108 | 3/19/2023 |
| 3.0.3 | 123 | 6/28/2022 |
| 3.0.2 | 117 | 5/17/2023 |
| 3.0.0 | 133 | 9/3/2022 |
| 3.0.0-rc1.19457.4 | 95 | 9/18/2022 |
| 3.0.0-preview9.19424.4 | 115 | 11/15/2022 |
| 3.0.0-preview8.19405.7 | 117 | 9/7/2022 |
| 3.0.0-preview7.19365.7 | 106 | 9/10/2022 |
| 3.0.0-preview6.19307.2 | 104 | 10/7/2022 |
| 3.0.0-preview5-19227-01 | 122 | 9/9/2022 |
| 3.0.0-preview4-19216-03 | 105 | 8/25/2022 |
| 3.0.0-preview3-19153-02 | 126 | 6/30/2022 |
| 3.0.0-preview-19075-0444 | 119 | 10/10/2022 |
| 3.0.0-preview-18579-0056 | 117 | 10/27/2022 |
| 2.3.9 | 13 | 1/10/2026 |
| 2.3.8 | 12 | 1/7/2026 |
| 2.3.0 | 82 | 1/19/2025 |
| 2.2.0 | 115 | 9/16/2022 |
| 2.2.0-preview3-35497 | 120 | 9/8/2022 |
| 2.2.0-preview2-35157 | 95 | 1/25/2023 |
| 2.2.0-preview1-35029 | 124 | 10/4/2022 |
| 2.1.1 | 101 | 5/16/2023 |
| 2.1.0 | 112 | 11/14/2022 |
| 2.1.0-rc1-final | 100 | 9/27/2022 |
| 2.1.0-preview2-final | 113 | 10/8/2022 |
| 2.1.0-preview1-final | 105 | 9/21/2022 |
| 2.0.0 | 121 | 10/1/2022 |
| 2.0.0-preview2-final | 129 | 9/30/2022 |
| 2.0.0-preview1-final | 134 | 10/17/2022 |
| 1.1.2 | 127 | 12/15/2022 |
| 1.1.1 | 148 | 6/30/2022 |
| 1.1.0 | 97 | 9/28/2022 |
| 1.1.0-preview1-final | 119 | 1/27/2023 |
| 1.0.0 | 122 | 10/3/2022 |
| 1.0.0-rc2-final | 114 | 10/4/2022 |