Skip to content

Latest commit

 

History

History
39 lines (31 loc) · 1.02 KB

DeepEquals.md

File metadata and controls

39 lines (31 loc) · 1.02 KB

Comparing JSON with JToken.DeepEquals

This sample compares Argon.JToken instances using Argon.JToken.DeepEquals(Argon.Linq.JToken,Argon.Linq.JToken), comparing the token and all child tokens.

var s1 = new JValue("A string");
var s2 = new JValue("A string");
var s3 = new JValue("A STRING");

Console.WriteLine(JToken.DeepEquals(s1, s2));
// true

Console.WriteLine(JToken.DeepEquals(s2, s3));
// false

var o1 = new JObject
{
    {"Integer", 12345},
    {"String", "A string"},
    {"Items", new JArray(1, 2)}
};

var o2 = new JObject
{
    {"Integer", 12345},
    {"String", "A string"},
    {"Items", new JArray(1, 2)}
};

Console.WriteLine(JToken.DeepEquals(o1, o2));
// true

Console.WriteLine(JToken.DeepEquals(s1, o1["String"]));
// true

snippet source | anchor