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.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/fc93e595ceffbb1e3e85532bf454e92a6a80dd6b
68
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/96103c264e5e8f0485d07018ba27b78cd8227dd2
67
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/55738ff96b832439076e25584cfe0eb3bace9b01
67
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/ae2eabad0e49302d0632a7dde917fdc68d960dc4
65
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/2924ca229b3d6c91b7c9eded119b31dfd7aa1fef
65
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/e56abc45c4f8adc518abfc11a59849d616431e2c
65
KubernetesClient
Client library for the Kubernetes open source container orchestrator.
65
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/0bc3c376f0cd14335e8b3afca69596acabeb1f80
64
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/432e6a061f28dda696ba16bc5442328d23b25d93
63
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/aspnet/AspNetCore/tree/80fec4e3edea3972e95885f5c0db6ee06072f917
62
KubernetesClient
Client library for the Kubernetes open source container orchestrator.
62
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/71dd6b0c87d7619668a40876d084d93db57eab41
62
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/aspnet/AspNetCore/tree/4d0b3722384bfec7d4c210674df9b7bf1e59da90
61
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/cdfa43bbe0ecc13757cc6517c9a253de77c3ec56
61
Microsoft.AspNetCore.Mvc.Formatters.Json
ASP.NET Core MVC formatters for JSON input and output and for JSON PATCH input using Json.NET.
61
KubernetesClient
Client library for the Kubernetes open source container orchestrator.
61
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/aspnet/AspNetCore/tree/2b7e994b8a304700a09617ffc5052f0d943bbcba
60
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/aspnet/AspNetCore/tree/b908e913e3befcfe241f3294509e6d9570acc07b
60
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/f9ae0f5d30be2de3c0de61b5673bd8873231d70a
60
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/aspnet/AspNetCore/tree/c04846dc66cc97f71d83a83a15437828435f5d44
60

.NET Framework 4.6.2

.NET 10.0

.NET Standard 2.0

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