using JsonDiffPatchDotNet;
using Newtonsoft.Json.Linq;
using System.Collections.Generic;
public static class JsonDiffPatchWrapper
private static readonly JsonDiffPatch JsonDiff = new JsonDiffPatch();
public static JToken Diff(Object oldResult, Object newResult)
if (newResult is null && oldResult is null)
return JToken.FromObject(oldResult);
return JToken.FromObject(newResult);
return JsonDiff.Diff(JToken.FromObject(oldResult), JToken.FromObject(newResult));
public static object TestJsonOne = new { Test = "", Value = "1" };
public static object TestJsonTwo = new { Value = "2" };
public static void Main()
var diffResult = JsonDiffPatchWrapper.Diff(TestJsonOne, TestJsonTwo);
if (diffResult is not null)
diffResult.SelectTokens("..Test").ToList().ForEach(t => t.Parent.Remove());
Console.WriteLine(diffResult);