Microsoft.AspNetCore.JsonPatch.SystemTextJson 10.0.0-preview.5.25280.105

Prefix Reserved
This is a prerelease version of Microsoft.AspNetCore.JsonPatch.SystemTextJson.
dotnet add package Microsoft.AspNetCore.JsonPatch.SystemTextJson --version 10.0.0-preview.5.25280.105
                    
NuGet\Install-Package Microsoft.AspNetCore.JsonPatch.SystemTextJson -Version 10.0.0-preview.5.25280.105
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Microsoft.AspNetCore.JsonPatch.SystemTextJson" Version="10.0.0-preview.5.25280.105" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Microsoft.AspNetCore.JsonPatch.SystemTextJson" Version="10.0.0-preview.5.25280.105" />
                    
Directory.Packages.props
<PackageReference Include="Microsoft.AspNetCore.JsonPatch.SystemTextJson" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Microsoft.AspNetCore.JsonPatch.SystemTextJson --version 10.0.0-preview.5.25280.105
                    
#r "nuget: Microsoft.AspNetCore.JsonPatch.SystemTextJson, 10.0.0-preview.5.25280.105"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=Microsoft.AspNetCore.JsonPatch.SystemTextJson&version=10.0.0-preview.5.25280.105&prerelease
                    
Install Microsoft.AspNetCore.JsonPatch.SystemTextJson as a Cake Addin
#tool nuget:?package=Microsoft.AspNetCore.JsonPatch.SystemTextJson&version=10.0.0-preview.5.25280.105&prerelease
                    
Install Microsoft.AspNetCore.JsonPatch.SystemTextJson as a Cake Tool

About

Microsoft.AspNetCore.JsonPatch.SystemTextJson provides ASP.NET Core support for JSON PATCH requests.

How to Use

To use Microsoft.AspNetCore.JsonPatch.SystemTextJson, follow these steps:

Installation

dotnet add package Microsoft.AspNetCore.JsonPatch.SystemTextJson

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.SystemTextJson is released as open-source under the MIT license. Bug reports and contributions are welcome at the GitHub repository.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.

GitHub repositories

This package is not used by any popular GitHub repositories.