Compare two JSON objects and map the difference to a third JSON object.
Published: 2022-06-14 08:29:41

I've got two json objects of different sizes. I want to compare both and lock the discrepancy into a third json object from the second json, keeping the first json object as base and returning only the keys and values that the first json has.
First JSON `[
    {
        "Title": "Ankit Singh1",
        "Aadhar_x0020_Nuber": 999941057058,
        "Age": 54,
        "Gender": "M",
        "Phone": 2810806979,
        "Father_x0020_Name": "Mr. Choudhury",
        "Email": "sschoudhury@dummyemail.com",
        "City": "New Delhi",
        "State": "New delhi"
    },
    {
        "Title": "Munendra",
        "Aadhar_x0020_Nuber": 999971658847,
        "Age": 44,
        "Gender": "M",
        "Phone": 2314475929,
        "Father_x0020_Name": "Mr. Agarwal",
        "Email": "kma@mailserver.com",
        "City": "Udaipur",
        "State": "Rajasthan"
    },
    {
        "Title": "Mayank Sharma3",
        "Aadhar_x0020_Nuber": 999933119405,
        "Age": 79,
        "Gender": "F",
        "Phone": 2837032088,
        "Father_x0020_Name": "Mr. Bedi",
        "Email": "bedi2020@mailserver.com",
        "City": "Bareilly",
        "State": "Uttar Pradesh"
    },
    {
        "Title": "Shikhar Saxena",
        "Aadhar_x0020_Nuber": 999955183433,
        "Age": 37,
        "Gender": "M",
        "Phone": 2821096353,
        "Father_x0020_Name": "Mr. Pandey",
        "Email": "rpandey@mailserver.com",
        "City": "Mumbai",
        "State": "Maharastra"
    },
    {
        "Title": "Namita Rastogi",
        "Aadhar_x0020_Nuber": 999990501894,
        "Age": 40,
        "Gender": "F",
        "Phone": 2821096350,
        "Father_x0020_Name": "Mr. Kapoor",
        "Email": "anisha@gmail.com",
        "City": "Bangalore",
        "State": "Karnataka"
    }
]`

Second JSON 
`[
    {
        "odata.type": "SP.Data.Aadhar_x005f_DataListItem",
        "odata.id": "387bcb99-2322-4c78-b051-11baed350c3b",
        "odata.etag": "\"3\"",
        "odata.editLink": "Web/Lists(guid'f57b8a37-9a12-48fa-ae4a-f2c360611fd2')/Items(1)",
        "Name@odata.navigationLinkUrl": "Web/Lists(guid'f57b8a37-9a12-48fa-ae4a-f2c360611fd2')/Items(1)/Name",
        "Name": {
            "odata.type": "SP.Data.UserInfoItem",
            "odata.id": "7a97126a-329f-405b-849c-71707a26dab1",
            "Title": "Ankit Singh"
        },
        "FileSystemObjectType": 0,
        "Id": 1,
        "ServerRedirectedEmbedUri": null,
        "ServerRedirectedEmbedUrl": "",
        "ID": 1,
        "ContentTypeId": "0x0100CAEC71E55732C14BA36095D2FA8E6CA80037B4C7B1E7CFFA4D83E55D30CD77AC99",
        "Title": null,
        "Modified": "2022-06-07T09:31:14Z",
        "Created": "2022-06-02T08:15:05Z",
        "AuthorId": 1282,
        "EditorId": 1282,
        "OData__UIVersionString": "3.0",
        "Attachments": false,
        "GUID": "c27f786a-8599-400c-b284-f7bec308a861",
        "ComplianceAssetId": null,
        "Aadhar_x0020_Nuber": 999941057058,
        "NameId": 1282,
        "NameStringId": "1282",
        "Age": 54,
        "Gender": "M",
        "Phone": 2810806979,
        "Father_x0020_Name": "Mr. Choudhury",
        "Email": "sschoudhury@dummyemail.com",
        "City": "New Delhi",
        "State": "New delhi"
    },
    {
        "odata.type": "SP.Data.Aadhar_x005f_DataListItem",
        "odata.id": "d24e0926-c984-41f0-9831-bc89b59c7dc7",
        "odata.etag": "\"1\"",
        "odata.editLink": "Web/Lists(guid'f57b8a37-9a12-48fa-ae4a-f2c360611fd2')/Items(2)",
        "Name@odata.navigationLinkUrl": "Web/Lists(guid'f57b8a37-9a12-48fa-ae4a-f2c360611fd2')/Items(2)/Name",
        "Name": {
            "odata.type": "SP.Data.UserInfoItem",
            "odata.id": "8e2ec76f-b771-4506-b375-107da0ebbe10",
            "Title": "Munendra"
        },
        "FileSystemObjectType": 0,
        "Id": 2,
        "ServerRedirectedEmbedUri": null,
        "ServerRedirectedEmbedUrl": "",
        "ID": 2,
        "ContentTypeId": "0x0100CAEC71E55732C14BA36095D2FA8E6CA80037B4C7B1E7CFFA4D83E55D30CD77AC99",
        "Title": null,
        "Modified": "2022-06-02T08:17:48Z",
        "Created": "2022-06-02T08:17:48Z",
        "AuthorId": 1282,
        "EditorId": 1282,
        "OData__UIVersionString": "1.0",
        "Attachments": false,
        "GUID": "afb84bd6-0253-4bf8-a515-824b13ae1a4e",
        "ComplianceAssetId": null,
        "Aadhar_x0020_Nuber": 999971658847,
        "NameId": 107,
        "NameStringId": "107",
        "Age": 44,
        "Gender": "M",
        "Phone": 2314475929,
        "Father_x0020_Name": "Mr. Agarwal",
        "Email": "kma@mailserver.com",
        "City": "Udaipur",
        "State": "Rajasthan"
    },
    {
        "odata.type": "SP.Data.Aadhar_x005f_DataListItem",
        "odata.id": "c852313d-94f1-4e2b-bef5-951e339e22c6",
        "odata.etag": "\"1\"",
        "odata.editLink": "Web/Lists(guid'f57b8a37-9a12-48fa-ae4a-f2c360611fd2')/Items(3)",
        "Name@odata.navigationLinkUrl": "Web/Lists(guid'f57b8a37-9a12-48fa-ae4a-f2c360611fd2')/Items(3)/Name",
        "Name": {
            "odata.type": "SP.Data.UserInfoItem",
            "odata.id": "a4caecd1-e862-4590-98e2-03d7bc09ef6c",
            "Title": "Mayank Sharma3"
        },
        "FileSystemObjectType": 0,
        "Id": 3,
        "ServerRedirectedEmbedUri": null,
        "ServerRedirectedEmbedUrl": "",
        "ID": 3,
        "ContentTypeId": "0x0100CAEC71E55732C14BA36095D2FA8E6CA80037B4C7B1E7CFFA4D83E55D30CD77AC99",
        "Title": null,
        "Modified": "2022-06-02T08:18:58Z",
        "Created": "2022-06-02T08:18:58Z",
        "AuthorId": 1282,
        "EditorId": 1282,
        "OData__UIVersionString": "1.0",
        "Attachments": false,
        "GUID": "e5ac3af3-e024-4703-b946-96cdc2ff3b5e",
        "ComplianceAssetId": null,
        "Aadhar_x0020_Nuber": 999933119405,
        "NameId": 705,
        "NameStringId": "705",
        "Age": 79,
        "Gender": "M",
        "Phone": 2837032088,
        "Father_x0020_Name": "Mr. Bedi",
        "Email": "bedi2020@mailserver.com",
        "City": "Bareilly",
        "State": "Uttar Pradesh"
    },
    {
        "odata.type": "SP.Data.Aadhar_x005f_DataListItem",
        "odata.id": "42a4e9aa-3646-4c1f-843c-6ccc6b6b5f6d",
        "odata.etag": "\"1\"",
        "odata.editLink": "Web/Lists(guid'f57b8a37-9a12-48fa-ae4a-f2c360611fd2')/Items(4)",
        "Name@odata.navigationLinkUrl": "Web/Lists(guid'f57b8a37-9a12-48fa-ae4a-f2c360611fd2')/Items(4)/Name",
        "Name": {
            "odata.type": "SP.Data.UserInfoItem",
            "odata.id": "0e444937-b8bf-463e-a462-d8a7d98a8222",
            "Title": "Shikhar Saxena"
        },
        "FileSystemObjectType": 0,
        "Id": 4,
        "ServerRedirectedEmbedUri": null,
        "ServerRedirectedEmbedUrl": "",
        "ID": 4,
        "ContentTypeId": "0x0100CAEC71E55732C14BA36095D2FA8E6CA80037B4C7B1E7CFFA4D83E55D30CD77AC99",
        "Title": null,
        "Modified": "2022-06-02T08:20:16Z",
        "Created": "2022-06-02T08:20:16Z",
        "AuthorId": 1282,
        "EditorId": 1282,
        "OData__UIVersionString": "1.0",
        "Attachments": false,
        "GUID": "c3395b35-a981-4754-abb5-8b4b0fe65a51",
        "ComplianceAssetId": null,
        "Aadhar_x0020_Nuber": 999955183433,
        "NameId": 846,
        "NameStringId": "846",
        "Age": 37,
        "Gender": "M",
        "Phone": 2821096353,
        "Father_x0020_Name": "Mr. Pandey",
        "Email": "rpandey@mailserver.com",
        "City": "Mumbai",
        "State": "Maharastra"
    },
    {
        "odata.type": "SP.Data.Aadhar_x005f_DataListItem",
        "odata.id": "ea969f4a-dbcf-43a6-8b94-b4deef12969d",
        "odata.etag": "\"2\"",
        "odata.editLink": "Web/Lists(guid'f57b8a37-9a12-48fa-ae4a-f2c360611fd2')/Items(5)",
        "Name@odata.navigationLinkUrl": "Web/Lists(guid'f57b8a37-9a12-48fa-ae4a-f2c360611fd2')/Items(5)/Name",
        "Name": {
            "odata.type": "SP.Data.UserInfoItem",
            "odata.id": "3cafee5d-7c5d-4e22-9568-751d37bc5223",
            "Title": "Namita Rastogi"
        },
        "FileSystemObjectType": 0,
        "Id": 5,
        "ServerRedirectedEmbedUri": null,
        "ServerRedirectedEmbedUrl": "",
        "ID": 5,
        "ContentTypeId": "0x0100CAEC71E55732C14BA36095D2FA8E6CA80037B4C7B1E7CFFA4D83E55D30CD77AC99",
        "Title": null,
        "Modified": "2022-06-09T07:25:17Z",
        "Created": "2022-06-02T08:21:46Z",
        "AuthorId": 1282,
        "EditorId": 1282,
        "OData__UIVersionString": "2.0",
        "Attachments": false,
        "GUID": "7a7d7906-442e-41eb-9f17-16f729fbb310",
        "ComplianceAssetId": null,
        "Aadhar_x0020_Nuber": 999990501894,
        "NameId": 849,
        "NameStringId": "849",
        "Age": 40,
        "Gender": "F",
        "Phone": 2821096351,
        "Father_x0020_Name": "Mr. Kapoor",
        "Email": "anisha@gmail.com",
        "City": "Bangalore",
        "State": "Karnataka"
    }
]`