using Newtonsoft.Json.Linq;
public static void Main()
string oldRuleData = "[{\"id\":1,\"operations\":{\"draft\":false,\"draftRestricted\":false,\"approve\":false,\"cancel\":false},\"amount\":null,\"approvals\":1,\"templateRequired\":false,\"locations\":[],\"allowedTimes\":[],\"allowedIpAddresses\":[],\"allowedSecCodes\":[],\"authTokenRequired\":false,\"accounts\":[],\"accountGroups\":[],\"subsidiaries\":[],\"subsidiaryGroups\":[]}]";
string newRuleData = "[{\"id\":1,\"operations\":{\"draft\":true,\"draftRestricted\":false,\"approve\":false,\"cancel\":false},\"amount\":null,\"approvals\":1,\"templateRequired\":false,\"locations\":[],\"allowedTimes\":[],\"allowedIpAddresses\":[],\"allowedSecCodes\":[],\"authTokenRequired\":false,\"accounts\":[],\"accountGroups\":[],\"subsidiaries\":[],\"subsidiaryGroups\":[]}]";
bool setNewValue = false;
if (string.IsNullOrWhiteSpace(oldRuleData) && string.IsNullOrWhiteSpace(newRuleData))
Console.WriteLine("Not different!");
if (string.IsNullOrWhiteSpace(oldRuleData) || string.IsNullOrWhiteSpace(newRuleData))
Console.WriteLine("Different!");
if (oldRuleData.StartsWith("[") && newRuleData.StartsWith("["))
JArray origData = string.IsNullOrWhiteSpace(oldRuleData) ? new JArray() : JArray.Parse(oldRuleData);
JArray newData = string.IsNullOrWhiteSpace(newRuleData) ? new JArray() : JArray.Parse(newRuleData);
if (!JToken.DeepEquals(origData, newData))
else if (oldRuleData.StartsWith("{") && newRuleData.StartsWith("{"))
JObject origData = string.IsNullOrWhiteSpace(oldRuleData) ? new JObject() : JObject.Parse(oldRuleData);
JObject newData = string.IsNullOrWhiteSpace(newRuleData) ? new JObject() : JObject.Parse(newRuleData);
if (!JToken.DeepEquals(origData, newData))
Console.WriteLine("Different!");
Console.WriteLine("Not different!");
Console.WriteLine(null != "test");