JSComparision 1.0.0
dotnet add package JSComparision --version 1.0.0
NuGet\Install-Package JSComparision -Version 1.0.0
<PackageReference Include="JSComparision" Version="1.0.0" />
paket add JSComparision --version 1.0.0
#r "nuget: JSComparision, 1.0.0"
// 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 | Versions 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
-
net6.0
- Newtonsoft.Json (>= 13.0.3)
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 | 222 | 1/3/2024 |