How to compare two Json objects using C#

后端 未结 6 1882
我在风中等你
我在风中等你 2021-02-05 19:57

I have two Json objects as below need to be compared. I am using Newtonsoft libraries for Json parsing.

string InstanceExpected = jsonExpected;
string InstanceAc         


        
6条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-05 20:42

    Consider using the JToken.DeepEquals() method provided by Newtonsoft. It would look somewhat like this, regardless of which testing framework you're using:

    Console.WriteLine(JToken.DeepEquals(InstanceObjActual, InstanceObjExpected));
    // false
    

提交回复
热议问题