Microsoft.AspNetCore.JsonPatch 10.0.0-preview.4.25258.110

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:

  1. Update your Program.cs with logic to construct a NewtonsoftJsonPatchInputFormatter:
    static NewtonsoftJsonPatchInputFormatter GetJsonPatchInputFormatter()
    {
        var builder = new ServiceCollection()
            .AddLogging()
            .AddMvc()
            .AddNewtonsoftJson()
            .Services.BuildServiceProvider();
    
        return builder
            .GetRequiredService<IOptions<MvcOptions>>()
            .Value
            .InputFormatters
            .OfType<NewtonsoftJsonPatchInputFormatter>()
            .First();
    }
    
  2. 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:

  1. Annotate it with the HttpPatch attribute
  2. Accept a JsonPatchDocument<TModel>
  3. 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
Microsoft.AspNetCore.App
Microsoft.AspNetCore.App
5
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/dotnet/tree/c22dcd0c7a78d095a94d20e59ec0271b9924c82c
4
Microsoft.AspNetCore.App
Microsoft.AspNetCore.App
4
Microsoft.AspNetCore.App
Provides a default set of APIs for building an ASP.NET Core application. This package requires the ASP.NET Core runtime. This runtime is installed by the .NET Core SDK, or can be acquired separately using installers available at https://aka.ms/dotnet-download.
4
Microsoft.AspNetCore.App
Provides a default set of API for building an ASP.NET Core application. This package requires the ASP.NET Core runtime. This runtime is installed by the .NET Core SDK, or can be acquired separately using installers available at https://aka.ms/dotnet-download. This package was built from the source at: https://github.com/aspnet/Universe/tree/c0686cbb3c353de256da1db32829d58143b567f5
4
Microsoft.AspNetCore.All
Provides a default set of APIs for building an ASP.NET Core application, and also includes API for third-party integrations with ASP.NET Core. This package requires the ASP.NET Core runtime. This runtime is installed by the .NET Core SDK, or can be acquired separately using installers available at https://aka.ms/dotnet-download.
4
Microsoft.AspNetCore.App
Provides a default set of APIs for building an ASP.NET Core application. This package requires the ASP.NET Core runtime. This runtime is installed by the .NET Core SDK, or can be acquired separately using installers available at https://aka.ms/dotnet-download.
3
KubernetesClient
Client library for the Kubernetes open source container orchestrator.
3
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/f5084525411d53b81d9950b68616117750b674d4
3
Microsoft.AspNetCore.App
Microsoft.AspNetCore.App
3
Microsoft.AspNetCore.All
Provides a default set of APIs for building an ASP.NET Core application, and also includes API for third-party integrations with ASP.NET Core. This package requires the ASP.NET Core runtime. This runtime is installed by the .NET Core SDK, or can be acquired separately using installers available at https://aka.ms/dotnet-download.
3
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/f050ae044be8bddc002ab88736e4bf78dc822122
3
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/ed74665e773dd1ebea3289c5662d71c590305932
2

.NET Framework 4.6.2

.NET 10.0

.NET Standard 2.0

Version Downloads Last updated
10.0.0-preview.5.25277.114 0 2025/6/6
10.0.0-preview.4.25258.110 4 2025/5/25
10.0.0-preview.3.25172.1 0 2025/4/10
10.0.0-preview.2.25164.1 2 2025/6/6
10.0.0-preview.1.25120.3 1 2025/6/6
9.0.5 3 2025/5/25
9.0.4 0 2025/4/8
9.0.3 0 2025/3/11
9.0.2 0 2025/2/11
9.0.1 0 2025/1/14
9.0.0 0 2024/11/12
9.0.0-rc.2.24474.3 0 2024/10/8
9.0.0-rc.1.24452.1 2 2025/5/27
9.0.0-preview.7.24406.2 1 2025/6/6
9.0.0-preview.6.24328.4 1 2025/6/4
9.0.0-preview.5.24306.11 0 2024/6/11
9.0.0-preview.4.24267.6 1 2025/6/4
9.0.0-preview.3.24172.13 0 2024/4/11
9.0.0-preview.2.24128.4 1 2025/6/6
9.0.0-preview.1.24081.5 1 2025/6/6
8.0.16 3 2025/5/25
8.0.15 1 2025/6/6
8.0.14 0 2025/3/11
8.0.13 0 2025/2/11
8.0.12 0 2025/1/14
8.0.11 0 2024/11/12
8.0.10 0 2024/10/8
8.0.8 0 2024/8/13
8.0.7 0 2024/7/9
8.0.6 1 2025/6/6
8.0.5 0 2024/5/14
8.0.4 0 2024/4/9
8.0.3 0 2024/3/12
8.0.2 0 2024/2/13
8.0.1 1 2025/5/25
8.0.0 0 2023/11/14
8.0.0-rc.2.23480.2 0 2023/10/10
8.0.0-rc.1.23421.29 0 2023/9/12
8.0.0-preview.7.23375.9 0 2023/8/8
8.0.0-preview.6.23329.11 1 2025/6/6
8.0.0-preview.5.23302.2 1 2025/6/6
8.0.0-preview.4.23260.4 1 2025/6/4
8.0.0-preview.3.23177.8 0 2023/4/11
8.0.0-preview.2.23153.2 0 2023/3/14
8.0.0-preview.1.23112.2 0 2023/2/21
7.0.20 0 2024/5/28
7.0.19 0 2024/5/14
7.0.18 0 2024/4/9
7.0.17 0 2024/3/12
7.0.16 0 2024/2/13
7.0.15 1 2025/6/6
7.0.14 1 2025/6/6
7.0.13 0 2023/10/24
7.0.12 0 2023/10/10
7.0.11 0 2023/9/12
7.0.10 0 2023/8/8
7.0.9 0 2023/7/11
7.0.8 0 2023/6/22
7.0.7 1 2025/6/6
7.0.5 0 2023/4/11
7.0.4 0 2023/3/14
7.0.3 0 2023/2/14
7.0.2 0 2023/1/10
7.0.1 0 2022/12/13
7.0.0 0 2022/11/7
7.0.0-rc.2.22476.2 1 2025/6/6
7.0.0-rc.1.22427.2 0 2022/9/14
7.0.0-preview.7.22376.6 1 2025/6/5
7.0.0-preview.6.22330.3 1 2025/6/6
7.0.0-preview.5.22303.8 0 2022/6/14
7.0.0-preview.4.22251.1 1 2025/6/7
7.0.0-preview.3.22178.4 1 2025/6/6
7.0.0-preview.2.22153.2 0 2022/3/14
7.0.0-preview.1.22109.13 1 2025/6/2
6.0.36 0 2024/11/12
6.0.35 0 2024/10/8
6.0.33 0 2024/8/13
6.0.32 0 2024/7/9
6.0.31 0 2024/5/28
6.0.30 0 2024/5/14
6.0.29 0 2024/4/9
6.0.28 0 2024/3/12
6.0.27 0 2024/2/13
6.0.26 0 2024/1/9
6.0.25 0 2023/11/14
6.0.24 0 2023/10/24
6.0.23 0 2023/10/10
6.0.22 0 2023/9/12
6.0.21 0 2023/8/8
6.0.20 0 2023/7/11
6.0.19 0 2023/6/22
6.0.18 0 2023/6/13
6.0.16 0 2023/4/11
6.0.15 0 2023/3/14
6.0.14 0 2023/2/14
6.0.13 0 2023/1/10
6.0.12 0 2022/12/13
6.0.11 0 2022/11/7
6.0.10 1 2025/6/6
6.0.9 0 2022/9/13
6.0.8 0 2022/8/9
6.0.7 0 2022/7/12
6.0.6 0 2022/6/14
6.0.5 1 2025/6/6
6.0.4 0 2022/4/11
6.0.3 1 2025/5/27
6.0.2 0 2022/2/8
6.0.1 0 2021/12/14
6.0.0 0 2021/11/8
6.0.0-rc.2.21480.10 0 2021/10/12
6.0.0-rc.1.21452.15 0 2021/9/14
6.0.0-preview.7.21378.6 1 2025/6/5
6.0.0-preview.6.21355.2 2 2025/6/6
6.0.0-preview.5.21301.17 2 2025/6/6
6.0.0-preview.4.21253.5 1 2025/6/3
6.0.0-preview.3.21201.13 1 2025/6/4
6.0.0-preview.2.21154.6 1 2025/6/7
6.0.0-preview.1.21103.6 1 2025/6/6
5.0.17 0 2022/5/10
5.0.16 0 2022/4/11
5.0.15 0 2022/3/8
5.0.14 0 2022/2/8
5.0.13 0 2021/12/14
5.0.12 0 2021/11/7
5.0.11 0 2021/10/12
5.0.10 0 2021/9/14
5.0.9 0 2021/8/10
5.0.8 0 2021/7/13
5.0.7 0 2021/6/8
5.0.6 0 2021/5/11
5.0.5 0 2021/4/6
5.0.4 0 2021/3/9
5.0.3 0 2021/2/9
5.0.2 0 2021/1/12
5.0.1 0 2020/12/8
5.0.0 0 2020/11/9
5.0.0-rc.2.20475.17 0 2020/10/13
5.0.0-rc.1.20451.17 0 2020/9/14
5.0.0-preview.8.20414.8 0 2020/8/25
5.0.0-preview.7.20365.19 2 2025/6/3
5.0.0-preview.6.20312.15 1 2025/6/6
5.0.0-preview.5.20279.2 0 2020/6/10
5.0.0-preview.4.20257.10 1 2025/6/6
5.0.0-preview.3.20215.14 1 2025/6/3
5.0.0-preview.2.20167.3 1 2025/6/5
5.0.0-preview.1.20124.5 1 2025/6/6
3.1.32 0 2022/12/13
3.1.31 1 2025/6/6
3.1.30 0 2022/10/11
3.1.29 1 2025/6/6
3.1.28 0 2022/8/9
3.1.27 0 2022/7/12
3.1.26 0 2022/6/14
3.1.25 0 2022/5/10
3.1.24 0 2022/4/11
3.1.23 0 2022/3/8
3.1.22 0 2021/12/14
3.1.21 0 2021/11/7
3.1.20 1 2025/6/6
3.1.19 0 2021/9/14
3.1.18 0 2021/8/10
3.1.17 0 2021/7/13
3.1.16 2 2025/6/6
3.1.15 0 2021/5/11
3.1.14 0 2021/4/6
3.1.13 0 2021/3/9
3.1.12 0 2021/2/9
3.1.11 0 2021/1/12
3.1.10 0 2020/11/9
3.1.9 0 2020/10/13
3.1.8 0 2020/9/8
3.1.7 1 2025/5/25
3.1.6 0 2020/7/14
3.1.5 0 2020/6/9
3.1.4 0 2020/5/12
3.1.3 0 2025/4/17
3.1.2 1 2025/6/6
3.1.1 1 2025/6/6
3.1.0 1 2025/6/7
3.1.0-preview3.19555.2 2 2025/6/5
3.1.0-preview2.19528.8 1 2025/6/4
3.1.0-preview1.19508.20 1 2025/5/31
3.0.3 0 2020/2/18
3.0.2 0 2020/1/14
3.0.0 0 2019/9/23
3.0.0-rc1.19457.4 0 2019/9/16
3.0.0-preview9.19424.4 1 2025/6/4
3.0.0-preview8.19405.7 2 2025/6/4
3.0.0-preview7.19365.7 1 2025/6/4
3.0.0-preview6.19307.2 1 2025/6/4
3.0.0-preview5-19227-01 1 2025/6/2
3.0.0-preview4-19216-03 1 2025/6/1
3.0.0-preview3-19153-02 1 2025/6/6
3.0.0-preview-19075-0444 1 2025/6/2
3.0.0-preview-18579-0056 1 2025/5/30
2.3.0 0 2025/1/14
2.2.0 2 2025/5/25
2.2.0-preview3-35497 1 2025/6/3
2.2.0-preview2-35157 1 2025/6/4
2.2.0-preview1-35029 1 2025/6/3
2.1.1 1 2025/6/6
2.1.0 1 2025/6/7
2.1.0-rc1-final 2 2025/5/31
2.1.0-preview2-final 2 2025/5/30
2.1.0-preview1-final 1 2025/5/30
2.0.0 0 2017/8/11
2.0.0-preview2-final 1 2025/5/30
2.0.0-preview1-final 1 2025/5/30
1.1.2 0 2017/5/9
1.1.1 1 2025/6/6
1.1.0 0 2016/11/16
1.1.0-preview1-final 1 2025/5/30
1.0.0 1 2025/6/6
1.0.0-rc2-final 1 2025/6/1