Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*.user
*.userosscache
*.sln.docstates
.archiveproject.xml

# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
Expand Down
4 changes: 2 additions & 2 deletions JsonDiffer.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29728.190
# Visual Studio Version 17
VisualStudioVersion = 17.3.32922.545
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JsonDiffer", "src\JsonDiffer\JsonDiffer.csproj", "{6B35C8F3-C82E-466A-9BBE-EC4322763A5F}"
EndProject
Expand Down
73 changes: 63 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# 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.
A lightweight utility to compare JSON objects and hence practically any serialize-able entity. This utility comes with two distinct 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.
Expand Down Expand Up @@ -52,7 +52,7 @@ Shows diffrences with "*" for changed properties "-" and "+" for removed and add
{
"-age": 30,
"*cars": {
"*car3": "Fiat",
"*car3": {"new": "Audi"},
"+car4": "Jaguar"
}
}
Expand All @@ -64,7 +64,7 @@ Shows diffrences with "*" for changed properties "-" and "+" for removed and add
var j1 = JToken.Parse(Read(json1));
var j2 = JToken.Parse(Read(json2));

var diff = JsonDifferentiator.Differentiate(j1,j2, showOriginalValues: true);
var diff = JsonDifferentiator.Differentiate(j1,j2, showValues: ShowValuesOptions.Original);

```

Expand All @@ -74,7 +74,31 @@ Shows diffrences with "*" for changed properties "-" and "+" for removed and add
{
"-age": 30,
"*cars": {
"*car3": "Audi",
"*car3": {"original": "Fiat"},
"+car4": "Jaguar"
}
}


```

## Usage 3
```csharp

var j1 = JToken.Parse(Read(json1));
var j2 = JToken.Parse(Read(json2));

var diff = JsonDifferentiator.Differentiate(j1,j2, showValues: ShowValuesOptions.OriginalAndNew);

```


## Result
```javascript
{
"-age": 30,
"*cars": {
"*car3": {"original": "Fiat", "new": "Audi"},
"+car4": "Jaguar"
}
}
Expand All @@ -94,7 +118,7 @@ Given the same json samples:
var j1 = JToken.Parse(Read(json1));
var j2 = JToken.Parse(Read(json2));

var diff = JsonDifferentiator.Differentiate(j1,j2, outputMode = OutputMode.Detailed);
var diff = JsonDifferentiator.Differentiate(j1,j2, outputMode: OutputMode.Detailed);

```

Expand All @@ -107,7 +131,7 @@ Given the same json samples:
"changed": {
"cars": {
"changed": {
"car3": "Fiat"
"car3": {"new": "Audi"}
},
"added": {
"car4": "Jaguar"
Expand All @@ -123,7 +147,36 @@ Given the same json samples:
var j1 = JToken.Parse(Read(json1));
var j2 = JToken.Parse(Read(json2));

var diff = JsonDifferentiator.Differentiate(j1,j2, outputMode = OutputMode.Detailed, showOriginalValues: true);
var diff = JsonDifferentiator.Differentiate(j1,j2, outputMode: OutputMode.Detailed, showValues: ShowValuesOptions.Original);

```

### Result
```javascript
{
"removed": {
"age": 30
},
"changed": {
"cars": {
"changed": {
"car3": {"original": "Fiat"}
},
"added": {
"car4": "Jaguar"
}
}
}
}
```

### Example 3
```csharp

var j1 = JToken.Parse(Read(json1));
var j2 = JToken.Parse(Read(json2));

var diff = JsonDifferentiator.Differentiate(j1,j2, outputMode: OutputMode.Detailed, showValues: ShowValuesOptions.OriginalAndNew);

```

Expand All @@ -136,7 +189,7 @@ Given the same json samples:
"changed": {
"cars": {
"changed": {
"car3": "Audi"
"car3": {"original": "Fiat", "new": "Audi"}
},
"added": {
"car4": "Jaguar"
Expand All @@ -152,7 +205,7 @@ Given the same json samples:
var j1 = JToken.Parse(Read(json1));
var j2 = JToken.Parse(Read(json2));

var differentiator = new JsonDifferentiator(OutputMode outputMode: OutputMode.Symbol, showOriginalValues: false);
var differentiator = new JsonDifferentiator(outputMode: OutputMode.Symbol, showValues: ShowValuesOptions.New);
var diff = differentiator.Differentiate(j1,j2);

```
Expand All @@ -166,7 +219,7 @@ Given the same json samples:
"changed": {
"cars": {
"changed": {
"car3": "Fiat"
"car3": {"new": "Audi"}
},
"added": {
"car4": "Jaguar"
Expand Down
Loading