JsonPatch.Net (5.0.2)

Published 2026-09-09 02:39:20 +03:30 by kayer

Installation

dotnet nuget add source --name kayer --username your_username --password your_token 
dotnet add package --source kayer --version 5.0.2 JsonPatch.Net

About this package

JSON Patch built on the System.Text.Json namespace

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.

Dependencies

ID Version Target Framework
JsonPointer.Net 7.0.1 .NETStandard2.0
JsonPointer.Net 7.0.1 net10.0
JsonPointer.Net 7.0.1 net8.0
JsonPointer.Net 7.0.1 net9.0
Details
NuGet
2026-09-09 02:39:20 +03:30
0
Greg Dennis
128 KiB
Assets (2)
Versions (1) View all
5.0.2 2026-09-09