JsonPatch.Net 3.2.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package JsonPatch.Net --version 3.2.2                
NuGet\Install-Package JsonPatch.Net -Version 3.2.2                
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="JsonPatch.Net" Version="3.2.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add JsonPatch.Net --version 3.2.2                
#r "nuget: JsonPatch.Net, 3.2.2"                
#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.
// Install JsonPatch.Net as a Cake Addin
#addin nuget:?package=JsonPatch.Net&version=3.2.2

// Install JsonPatch.Net as a Cake Tool
#tool nuget:?package=JsonPatch.Net&version=3.2.2                

Summary

JsonPatch.Net implements JSON Patch, RFC 6902, a JSON document structure for expressing a sequence of operations to apply to another JSON document.

Usage

Deserialize and apply immediately:

var patch = JsonSerializer.Deserialize<JsonPatch>(patchString);
var doc = JsonNode.Parse(docString);
var result = patch.Apply(doc);

Or you can build a patch inline:

var patch = new JsonPatch(PatchOperation.Add("/foo/bar", "baz"),
                          PatchOperation.Test("/foo/biz", false));

There is also limited patch generation support:

// parse your data
var start = JsonNode.Parse("[{\"test\":\"test123\"},{\"test\":\"test321\"},{\"test\":[1,2,3]},{\"test\":[1,2,4]}]");
// or build it inline
var target = new JsonArray{
  new JsonObject { ["test"] = "test123" },
  new JsonObject { ["test"] = "test32132" },
  new JsonObject { ["test1"] = "test321" },
  new JsonObject { ["test"] = new JsonArray{ 1, 2, 3 } },
  new JsonObject { ["test"] = new JsonArray{ 1, 2, 3 } },
}

var patch = start.CreatePatch(target);

/*
Result:
[
  {"op":"replace","path":"/1/test","value":"test32132"},
  {"op":"remove","path":"/2/test"},
  {"op":"add","path":"/2/test1","value":"test321"},
  {"op":"replace","path":"/3/test/2","value":3},
  {"op":"add","path":"/4","value":{"test":[1,2,3]}}
]
*/

Sponsorship

If you found this library helpful and would like to promote continued development, please consider sponsoring the maintainers.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (62)

Showing the top 5 NuGet packages that depend on JsonPatch.Net:

Package Downloads
Aspire.Hosting

Core abstractions for the .NET Aspire application model.

Aspire.Hosting.AppHost

Core library and MSBuild logic for .NET Aspire AppHost projects.

Aspire.Hosting.Azure

Azure resource types for .NET Aspire.

Aspire.Hosting.Redis

Redis® support for .NET Aspire.

Proto.Cluster.Kubernetes

Ultra-fast distributed actors for .NET.

GitHub repositories (6)

Showing the top 5 popular GitHub repositories that depend on JsonPatch.Net:

Repository Stars
umbraco/Umbraco-CMS
Umbraco is a free and open source .NET content management system helping you deliver delightful digital experiences.
dotnet/aspire
Tools, templates, and packages to accelerate building observable, production-ready apps
asynkron/protoactor-dotnet
Proto Actor - Ultra fast distributed actors for Go, C# and Java/Kotlin
kubernetes-client/csharp
Officially supported dotnet Kubernetes Client library
NosCoreIO/NosCore
NosCore is a Nostale emulator in c# (.Net 8) using DotNetty / Entity Framework / WebAPI / Autofac / Mapster / Serilog
Version Downloads Last updated
3.2.3 17,413 12/5/2024
3.2.2 2,185 12/3/2024
3.2.1 814 12/3/2024
3.2.0 2,012 11/30/2024
3.1.1 589,813 7/2/2024
3.1.0 182,179 5/1/2024
3.0.0.2 52,753 4/19/2024
3.0.0.1 131 4/19/2024
3.0.0 183,803 2/3/2024
2.1.0 690,230 6/12/2023
2.0.6 264,188 3/9/2023
2.0.5 5,490 3/7/2023
2.0.4 390,192 8/20/2022
2.0.3 1,712 8/12/2022
2.0.2 46,282 6/18/2022
2.0.1 19,481 6/16/2022
2.0.0 2,459 6/13/2022
1.1.2 287,000 12/5/2021
1.1.1 3,226 11/11/2021
1.1.0 61,098 9/13/2021
1.0.6 10,599 7/25/2021
1.0.5 2,376 6/20/2021
1.0.4 12,693 1/1/2021
1.0.3 625 12/19/2020
1.0.1 552 10/18/2020
1.0.0 819 10/16/2020

Release notes can be found at https://docs.json-everything.net/rn-json-patch/