Skip to content

Output to JSON

Greg Finzer edited this page Feb 15, 2022 · 1 revision

JSON output is not built into Compare .NET Objects. You would need to use something like Newtonsoft Json: https://www.nuget.org/packages/Newtonsoft.Json/

Person p1 = null;
Person p2 = new Person();
ComparisonResult result = _compare.Compare(p1, p2);
string json = JsonConvert.SerializeObject(result.Differences, Formatting.Indented);