JsonPatch.Net 3.1.1

dotnet add package JsonPatch.Net --version 3.1.1                
NuGet\Install-Package JsonPatch.Net -Version 3.1.1                
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.1.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add JsonPatch.Net --version 3.1.1                
#r "nuget: JsonPatch.Net, 3.1.1"                
#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.1.1

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

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. 
.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 (58)

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.

Proto.Cluster.Kubernetes

Ultra-fast distributed actors for .NET.

Aspire.Hosting.Azure

Azure resource types for .NET Aspire.

Aspire.Hosting.Redis

Redis® support for .NET Aspire.

GitHub repositories (5)

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.
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
corvus-dotnet/Corvus.JsonSchema
Support for Json Schema validation and entity generation
Version Downloads Last updated
3.1.1 313,140 7/2/2024
3.1.0 161,427 5/1/2024
3.0.0.2 44,518 4/19/2024
3.0.0.1 121 4/19/2024
3.0.0 177,680 2/3/2024
2.1.0 672,706 6/12/2023
2.0.6 261,649 3/9/2023
2.0.5 5,462 3/7/2023
2.0.4 385,088 8/20/2022
2.0.3 1,702 8/12/2022
2.0.2 44,868 6/18/2022
2.0.1 19,272 6/16/2022
2.0.0 2,442 6/13/2022
1.1.2 282,365 12/5/2021
1.1.1 3,219 11/11/2021
1.1.0 61,071 9/13/2021
1.0.6 10,185 7/25/2021
1.0.5 2,369 6/20/2021
1.0.4 12,562 1/1/2021
1.0.3 616 12/19/2020
1.0.1 545 10/18/2020
1.0.0 721 10/16/2020

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