I am sharing stackblitz url as the Javascript Objects are quite long and won't fit in the body. The first object(objOne) is the original one and the second object(objTwo) has some changes in it.
I am finding it difficult to traverse and track out the difference along with some unique ID's. The Ownership Information List array contains two objects and has a unique id key to them then traversing down to ContractorLegalIssue( it has n no of objects and we have to check the object containing LegalIssueEntry which is not an empty array), it has ContractorLegalIssueID, LegalIssueTypeID as unique key then traversing down to LegalIssueEntry(it also has n no of objects) , it has LegalIssueEntryID, ContractorLegalIssueID as unique key and then to LegalIssueDetail in which the comparison with take place and take out the keys which have the difference along with some additional keys "id", "type","LegalIssueFieldTypeID","LegalIssueTypeID".
The Final result of the difference should be like this.
{
difference: [
{
id: 1,
ContractorLegalIssue: [
{
ContractorLegalIssueID: 1597,
LegalIssueTypeID: 1,
LegalIssueEntry: [
{
LegalIssueEntryID: 1151,
ContractorLegalIssueID: 1597,
LegalIssueDetail: [
{
id: 2,
value: "changed pos1",
"type": "Text",
"LegalIssueFieldTypeID": 2,
"FieldDetailText": "changed pos1",
"LegalIssueTypeID": 1
}
]
}
]
}
]
},
{
id: 2,
ContractorLegalIssue: [
{
ContractorLegalIssueID: 1599,
LegalIssueTypeID: 2,
LegalIssueEntry: [
{
LegalIssueEntryID: 1154,
ContractorLegalIssueID: 1599,
LegalIssueDetail: [
{
"id": 9,
"value": "4",
"type": "INT",
"LegalIssueTypeID": 2,
"LegalIssueFieldTypeID": 9,
"FieldDetailInt": 4
},
{
"id": 10,
"value": "changed for owner",
"type": "Text",
"LegalIssueTypeID": 2,
"LegalIssueFieldTypeID": 10,
"FieldDetailText": "changed for owner"
}
]
}
]
}
]
}
]
}
Please help me out in this.