C#JsonArray比较忽略了属性的顺序

时间:2018-04-07 09:50:22

标签: c# arrays json json.net

我正在使用JsonDiffPatch和C#来比较以下两个json。我无法弄清楚如何在比较时忽略数组内的排序。两个json如下:传输地址内的传输类型是两个json中的不同顺序(第一个有电子邮件和电话,第二个有电话和电子邮件。

first Json File
 "TestContacts": [
    {
      "$values": [
        {
          "Contact": {
            "Addresses": {
              "$values": [
                {
                  "Contact": {},
                  "TransmissionAddresses": {
                    "$values": [
                      {
                        "FirstLine": "test.test1@test.com.au",
                        "TransmissionType": "EMAIL",
                        "AI": {
                          "CNM": "SYSTEM",                              
                        },
                        "V": 0
                      },
                      {
                        "FirstLine": "+11 0 1234 5678",
                        "TransmissionType": "TELEPHONE",
                        "AI": {
                          "CNM": "SYSTEM",


                        },
                        "V": 0
                      }
                    ]
                  },

第二个json文件

{
          "Contact": {
            "Addresses": {
              "$values": [
                {
                  "Contact": {},
                  "TransmissionAddresses": {
                    "$values": [
                      {
                        "FirstLine": "+11 0 1234 5678",
                        "TransmissionType": "TELEPHONE",
                        "AI": {
                          "CNM": "SYSTEM",                            

                        },
                        "V": 0
                      },
                      {
                        "FirstLine": "test.test1@test.com.au",
                        "TransmissionType": "EMAIL",
                        "AI": {
                          "CNM": "SYSTEM",                             
                        },
                        "V": 0
                      }
                    ]
                  },

0 个答案:

没有答案