ThorstenHans.JsonPatch.Contrib 0.0.3

dotnet add package ThorstenHans.JsonPatch.Contrib --version 0.0.3
NuGet\Install-Package ThorstenHans.JsonPatch.Contrib -Version 0.0.3
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="ThorstenHans.JsonPatch.Contrib" Version="0.0.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ThorstenHans.JsonPatch.Contrib --version 0.0.3
#r "nuget: ThorstenHans.JsonPatch.Contrib, 0.0.3"
#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 ThorstenHans.JsonPatch.Contrib as a Cake Addin
#addin nuget:?package=ThorstenHans.JsonPatch.Contrib&version=0.0.3

// Install ThorstenHans.JsonPatch.Contrib as a Cake Tool
#tool nuget:?package=ThorstenHans.JsonPatch.Contrib&version=0.0.3

ThorstenHans.JsonPatch.Contrib

Release Build

The main purpose of this NuGet package is to simplify the usage of JsonPatchDocument<T> (Microsoft.AspNetCore.JsonPatch) when generating JSON patch expressions.

This is especially handy when working with SDKs like for example the official Kubernetes Client SDK for C#.

The package takes care about specifying proper ContractResolvers and producing valid JSON patch expressions as string by removing unsupported properties before serializing into a string.

public class TestModel
{
    public string FirstName { get; set; }
    public int Age { get; set; }
}

public class Examples 
{

    public static void Sample1()
    {
        var doc = JsonPatchDocumentBuilder.BuildFor<TestModel>();
        doc.Replace(t => t.FirstName, "John");
        doc.Replace(t => t.Age, 42);

        var patchString = doc.ToJsonPatch();
        Console.WriteLine(patchString);
    }

}

Invoking Examples.Sample1() will print the following string to the console:

[
    {
        "path":"/firstName",
        "op":"replace",
        "value":"John"
    },
    {
        "path":"/age",
        "op":"replace",
        "value":42
    }
]
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.0.3 393 9/1/2022
0.0.2 157 9/1/2022