jkone27 / JsonDiffPatchExtensions

some extensions to jsondiffpatch dotnet to allow ignoring specific fields

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JsonDiffPatchExtensions NuGet Badge

some extensions to jsondiffpatch dotnet to allow ignoring specific fields

Ignore Properties

 [Fact]
    public void JsonDiffPatchWrapper_IgnoreDiff_Ok()
    {

        var objectOne = new { 
            TestField = "hello",
            A = "A"
        };

         var objectTwo = new { 
            TestField = "hello"
        };

        var diffObj = JsonDiffPatchWrapper.DiffIgnoreProperties(
            OldResult.From(objectOne), 
            NewResult.From(objectTwo),
            ignoreProperties: "A");

        Assert.Null(diffObj);
    }

Ignore casing in diffs

    [Fact]
    public void JsonDiffPatchWrapper_IgnoreCasing_Ok()
    {

        var objectOne = new { 
            TestField = "hello",
            A = "HELLO"
        };

         var objectTwo = new { 
            TestField = "hello",
            A = "hello"
        };

        var diffObj = JsonDiffPatchWrapper.DiffIgnoreCasingInValuesForProperties(
            OldResult.From(objectOne), 
            NewResult.From(objectTwo),
            ignoreCasingForProperties: "A");

        Assert.Null(diffObj);
    }

About

some extensions to jsondiffpatch dotnet to allow ignoring specific fields

License:MIT License


Languages

Language:C# 100.0%