JsonDiffer 1.0.1
dotnet add package JsonDiffer --version 1.0.1
NuGet\Install-Package JsonDiffer -Version 1.0.1
<PackageReference Include="JsonDiffer" Version="1.0.1" />
paket add JsonDiffer --version 1.0.1
#r "nuget: JsonDiffer, 1.0.1"
// Install JsonDiffer as a Cake Addin
#addin nuget:?package=JsonDiffer&version=1.0.1
// Install JsonDiffer as a Cake Tool
#tool nuget:?package=JsonDiffer&version=1.0.1
JsonDiffer.NetStandard
A lightweight utility to compare JSON objects and hence practically any serialize-able entity. This utility comes with two distincrt object models, adhoc and detailed.
- Adhoc object model shows diffrences with "*" for changed properties "-" and "+" for removed and added ones respectively.
- Detailed object models groups changes in three properties: changed, added and removed.
This library uses Newtonsoft.Json as the underlying engine.
Note: Legacy version should work as they did before thanks to optional parameters added to the new functionalities.
ADHOC Object Model
Shows diffrences with "*" for changed properties "-" and "+" for removed and added ones respectively.
JSON 1
{
"name":"John",
"age":30,
"cars": {
"car1":"Ford",
"car2":"BMW",
"car3":"Fiat"
}
}
JSON 2
{
"name":"John",
"cars": {
"car1":"Ford",
"car2":"BMW",
"car3":"Audi",
"car4":"Jaguar"
}
}
Usage 1
var j1 = JToken.Parse(Read(json1));
var j2 = JToken.Parse(Read(json2));
var diff = JsonDifferentiator.Differentiate(j1,j2);
Result
{
"-age": 30,
"*cars": {
"*car3": "Fiat",
"+car4": "Jaguar"
}
}
Usage 2
var j1 = JToken.Parse(Read(json1));
var j2 = JToken.Parse(Read(json2));
var diff = JsonDifferentiator.Differentiate(j1,j2, showOriginalValues: true);
Result
{
"-age": 30,
"*cars": {
"*car3": "Audi",
"+car4": "Jaguar"
}
}
Detailed Object Model
As mentioned this new object model groups changes in removed, changed and added properties in the result object recursively. Given the same json samples:
Simple Usage
Example 1
var j1 = JToken.Parse(Read(json1));
var j2 = JToken.Parse(Read(json2));
var diff = JsonDifferentiator.Differentiate(j1,j2, outputMode = OutputMode.Detailed);
Result
{
"removed": {
"age": 30
},
"changed": {
"cars": {
"changed": {
"car3": "Fiat"
},
"added": {
"car4": "Jaguar"
}
}
}
}
Example 2
var j1 = JToken.Parse(Read(json1));
var j2 = JToken.Parse(Read(json2));
var diff = JsonDifferentiator.Differentiate(j1,j2, outputMode = OutputMode.Detailed, showOriginalValues: true);
Result
{
"removed": {
"age": 30
},
"changed": {
"cars": {
"changed": {
"car3": "Audi"
},
"added": {
"car4": "Jaguar"
}
}
}
}
Using Constructor for configuration
var j1 = JToken.Parse(Read(json1));
var j2 = JToken.Parse(Read(json2));
var differentiator = new JsonDifferentiator(OutputMode outputMode: OutputMode.Symbol, showOriginalValues: false);
var diff = differentiator.Differentiate(j1,j2);
Result
{
"removed": {
"age": 30
},
"changed": {
"cars": {
"changed": {
"car3": "Fiat"
},
"added": {
"car4": "Jaguar"
}
}
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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. |
.NET Core | netcoreapp1.0 was computed. netcoreapp1.1 was computed. netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard1.3 is compatible. netstandard1.4 was computed. netstandard1.5 was computed. netstandard1.6 was computed. netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net35 is compatible. net40 is compatible. net403 was computed. net45 is compatible. net451 was computed. net452 was computed. net46 is compatible. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen30 was computed. tizen40 was computed. tizen60 was computed. |
Universal Windows Platform | uap was computed. uap10.0 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 3.5
- Newtonsoft.Json (>= 12.0.3)
-
.NETFramework 4.0
- Newtonsoft.Json (>= 12.0.3)
-
.NETFramework 4.5
- Newtonsoft.Json (>= 12.0.3)
-
.NETFramework 4.6
- Newtonsoft.Json (>= 12.0.3)
-
.NETStandard 1.3
- NETStandard.Library (>= 1.6.1)
- Newtonsoft.Json (>= 12.0.3)
-
.NETStandard 2.0
- Newtonsoft.Json (>= 12.0.3)
-
.NETStandard 2.1
- Newtonsoft.Json (>= 12.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.