{"id":16191192,"url":"https://github.com/havunen/systemtextjsonpatch","last_synced_at":"2026-04-02T23:23:06.789Z","repository":{"id":37088511,"uuid":"493589889","full_name":"Havunen/SystemTextJsonPatch","owner":"Havunen","description":"SystemTextJsonPatch is a JSON Patch (JsonPatchDocument) RFC 6902 implementation for .NET using System.Text.Json","archived":false,"fork":false,"pushed_at":"2025-01-17T07:06:16.000Z","size":339,"stargazers_count":113,"open_issues_count":6,"forks_count":15,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-04-01T00:33:53.807Z","etag":null,"topics":["dotnet","jsonpatchdocument","rfc6902","systemtextjson"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Havunen.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-05-18T09:11:35.000Z","updated_at":"2025-03-22T11:50:13.000Z","dependencies_parsed_at":"2023-11-14T19:24:54.933Z","dependency_job_id":"248ec73c-b350-4c67-8011-6f18a689de80","html_url":"https://github.com/Havunen/SystemTextJsonPatch","commit_stats":{"total_commits":144,"total_committers":10,"mean_commits":14.4,"dds":0.5694444444444444,"last_synced_commit":"a7434e946849dda9f52f7eb08f64fb7e9b5df162"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Havunen%2FSystemTextJsonPatch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Havunen%2FSystemTextJsonPatch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Havunen%2FSystemTextJsonPatch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Havunen%2FSystemTextJsonPatch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Havunen","download_url":"https://codeload.github.com/Havunen/SystemTextJsonPatch/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247760997,"owners_count":20991531,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dotnet","jsonpatchdocument","rfc6902","systemtextjson"],"created_at":"2024-10-10T07:45:17.872Z","updated_at":"2026-04-02T23:23:06.781Z","avatar_url":"https://github.com/Havunen.png","language":"C#","readme":"![SystemTextJsonPatchLogo](https://raw.githubusercontent.com/Havunen/SystemTextJsonPatch/main/logo.png)\n\n[![CI status](https://img.shields.io/github/actions/workflow/status/Havunen/SystemTextJsonPatch/ci.yml?branch=main\u0026logo=GitHub)](https://github.com/Havunen/SystemTextJsonPatch/actions/workflows/ci.yml)\n[![Nuget](https://img.shields.io/nuget/v/SystemTextJsonPatch?color=teal\u0026logo=Nuget)](https://www.nuget.org/packages/SystemTextJsonPatch#readme-body-tab)\n\n\n# System Text Json Patch\n\nSystemTextJsonPatch is a JSON Patch (JsonPatchDocument) RFC 6902 implementation for .NET using System.Text.Json\n\nThis library tries to ease the migration from Newtonsoft.Json to System.Text.Json by providing\nsimilar API for HttpPatch requests as in [Microsoft.AspNetCore.JsonPatch](https://github.com/dotnet/aspnetcore/tree/main/src/Features/JsonPatch) and [Marvin.JsonPatch](https://github.com/KevinDockx/JsonPatch)\n\n* Designed as an easy replacement for Microsoft.AspNetCore.JsonPatch\n* Supports .NET 6+ including .NET 10, plus netstandard2.0\n\n\n## Getting started\n\nBuild a patch document on the client.\nYou can use the operations as described in the IETF document: Add, Remove, Replace, Copy, Move and Test.\n\n```cs\nList\u003cOperation\u003cDTO.Expense\u003e\u003e operations = [];\nJsonSerializerOptions jsonOptions = new JsonSerializerOptions();\nJsonPatchDocument\u003cDTO.Expense\u003e expensePatch = new JsonPatchDocument\u003cDTO.Expense\u003e(operations,  jsonOptions);\nexpensePatch.Replace(e =\u003e e.Description, expense.Description);\n\n// serialize it to JSON\nvar expensePatchJson = System.Text.Json.JsonSerializer.Serialize(expensePatch);\n```\n\n\nOn your API, in the patch method (accept document as parameter \u0026 use ApplyTo method)\n\n```cs\n[Route(\"api/expenses/{id}\")]\n[HttpPatch]\npublic IHttpActionResult Patch(\n    int id,\n    [FromBody] JsonPatchDocument\u003cDTO.Expense\u003e expensePatchDocument\n)\n{\n      // get the expense from the repository\n      var expense = _repository.GetExpense(id);\n\n      // apply the patch document \n      expensePatchDocument.ApplyTo(expense);\n\n      // changes have been applied to expense object\n}\n```\n\n## Deny access to properties\nIf you need to stop JsonPatch from reading or writing to some properties,\nthen you can decorate them with `[DenyPatch]`, if a patch occurs that happens to access the property then a `JsonPatchAccessDeniedException` is thrown.\n\n\n## Migration from v1\n\nJsonPatchDocumentConverterFactory no longer needs to be set to JsonSerializerOptions.\nInstead JsonPatchDocument types now use JsonConvertAttribute to use the correct converter.\n\n## Performance comparison\n\nThis test deserializes a JSON patch document of 8 operations and applies the changes to a new model.\n\nSee [SystemTextJsonPatch.Benchmark](https://github.com/Havunen/SystemTextJsonPatch/tree/main/SystemTextJsonPatch.Benchmark) for more details.\n\nBenchmarkDotNet v0.15.8, Windows 11 (10.0.26200.8117/25H2/2025Update/HudsonValley2)\nAMD Ryzen 9 5950X 3.40GHz, 1 CPU, 32 logical and 16 physical cores\n.NET SDK 10.0.201\n  [Host]     : .NET 10.0.5 (10.0.5, 10.0.526.15411), X64 RyuJIT x86-64-v3\n  Job-PGIYFE : .NET 10.0.5 (10.0.5, 10.0.526.15411), X64 RyuJIT x86-64-v3\n\nWarmupCount=2\n\n| Method              | Mean       | Error      | StdDev     | Gen0   | Gen1   | Allocated |\n|-------------------- |-----------:|-----------:|-----------:|-------:|-------:|----------:|\n| SystemTextJsonPatch |   3.495 us |  0.0409 us |  0.0362 us | 0.2823 |      - |   4.63 KB |\n| MarvinJsonPatch     | 815.664 us | 15.7153 us | 18.7079 us | 3.9063 | 1.9531 |  68.01 KB |\n| AspNetCoreJsonPatch |  14.385 us |  0.2321 us |  0.2172 us | 2.5940 | 0.0610 |  42.56 KB |\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhavunen%2Fsystemtextjsonpatch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhavunen%2Fsystemtextjsonpatch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhavunen%2Fsystemtextjsonpatch/lists"}