JSComparision 1.0.0

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

// Install JSComparision as a Cake Tool
#tool nuget:?package=JSComparision&version=1.0.0

DNJ_comparison

Introduction

This package will allow you to compare 2 Json string and and get result. The main feature here is you can select specific field to monitor change. For example, you don't need to compare some fields such as created_at, updated_at, deleted_at, created_by,,,, etc. and you compare the field that your business interest to. Also, other feature is managing 3 field types text, object and array.

The output will be an object contain 2 object

Field and field types

the syntax to pass the keys is

 <type?:><fieldname>,

for object the fields separator is ;

examples

Given this 2 Json objects:
/// before
{
  "identifier": 4444,
  "letters": ["a", "b", "c"],
  "owners": [
    { "id": 1, "role": "owner", "age": 4, "name": "Jabber" },
    { "id": 3, "role": "owner", "name": "Yousef" },
    { "id": 2, "role": "partner", "name": "YouseF" }
  ]
}
/// after
{
  "identifier": 4444,
  "letters": ["a", "b", "x", "y"],
  "owners": [
    { "id": 1, "role": "owner", "age": 4, "name": "Jabber" },
    { "id": 2, "role": "owner", "name": "YouseF" }
  ]
}

you may use below script to find the difference between above Json objects.


    JSCompare jSCompare = new JSCompare();

    JObject beforeObj = JObject.Parse(beforeJson);
    JObject afterObj = JObject.Parse(afterJson);

    string field = "identifier,array:letters,object:owners|id;role";

    JObject result = jSCompare.Compare(beforeObj, afterObj, field);
    Console.WriteLine(result);

The output will be:

{
  "before": {
    "identifier": "44",
    "letters": [
      "c"
    ],
    "owners": [
      {
        "id": 2,
        "role": "partner",
        "name": "YouseF"
      },
      {
        "id": 3,
        "role": "owner",
        "name": "Yousef"
      }
    ]
  },
  "after": {
    "identifier": "4444",
    "letters": [
      "x",
      "y"
    ],
    "owners": [
      {
        "id": 2,
        "role": "owner",
        "name": "YouseF"
      }
    ]
  }
}
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
1.0.0 178 1/3/2024