Link to home
Start Free TrialLog in
Avatar of John S.
John S.Flag for United States of America

asked on

Array Help again - compare and return new one

I recently asked a similar question but left out some important stuff. Here goes again...

Source Array
I have an array of items that looks like the following code. There can and will be many items in here.
[
    {
        "ItemId": "12345",
	"rmaId": "777",
        "UPC": "73343324400098",
        "Name": "Time Machine",
        "Description": "A new product you will love",
        "SerialNumberRequired": true,
        "Notes": "This is a note someone just entered",
        "Condition": 2,
        "Qty": 2,
        "SerialNumber": [
            "33",
            "34"
        ]
    },

   {
// more items will be here
}

]

Open in new window

Edit Array
I have a second array that looks like this. There will only be one object in this array.
[
    {
        "ItemId": "12345",
	"rmaId": "777",
        "UPC": "73343324400098",
        "Name": "Time Machine",
        "Description": "A new product you will love",
        "SerialNumberRequired": true,
        "Notes": "This is a note someone just entered",
        "Condition": 2,
        "Qty": 2,
        "SerialNumber": [
            "11112222",
            "3333344444"
        ]
    }
]

Open in new window

Based on the itemId in Edit array, I need any changes that don't match the source array returned to me in an array in this format.
For instance, if I am editing itemID 12345...
So if an item in the source array has two serial numbers, and both were changed, the result would be:

Desired Return Array
[
{
   rmaId: "777",
   itemId: "12345",
   serialNumber: "11112222",
   notes: "Some Notes",
   condition: "Good"	
},
{
   rmaId: "777",
   itemId: "12345",
   serialNumber: "3333344444",
   notes: "Some Notes",
   condition: "Good"
}

]

Open in new window


Some things to note:

1. rmaId, itemId, upc, name, qty cannot/will not be change.
2. some items may NOT have any serial numbers, so we need to still track notes and description
3. The return array only has those 5 properties, that is deliberate.

THANKS. I way above my paygrade on this one, lol
SOLUTION
Avatar of Rainer Jeschor
Rainer Jeschor
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of John S.

ASKER

I was just notified that we changed the API which makes this question not my problem anymore, Thank you,