Link to home
Start Free TrialLog in
Avatar of Zolf
ZolfFlag for United Arab Emirates

asked on

Manipulate JSON Array in Angular

Hi there,

I have this two Array and want to get some of the values from one array into another. Can someone please help.
newData {"id":10,"receiptno":"777","contractmfg":4,"entrydate":"2020-09-04","rawmaterialwh":[{"qty":100},{"qty":20}]}


oldData {"id":10,"receiptno":"777","contractmfg":4,"entrydate":"2020-09-04","rawmaterialwh":[{"supplier":5,"rawmaterialid":16,"qty":10},{"supplier":11,"rawmaterialid":8,"qty":20}]}

Open in new window


I want to get the rawmaterialwh array's supplier and rawmaterialid and insert it in the newData's rawmaterialwh array,so that my newData JSON aray will look like so,

transformedData {"id":10,"receiptno":"777","contractmfg":4,"entrydate":"2020-09-04","rawmaterialwh":[{"supplier":5,"rawmaterialid":16,"qty":100},{"supplier":11,"rawmaterialid":8,"qty":20}]}

Open in new window

Thanks!!
Avatar of HainKurt
HainKurt
Flag of Canada image

try

newData.rawmaterialwh = oldData.rawmaterialwh;
Avatar of Zolf

ASKER

Thanks for your comments.
It is populating the newData with the supplier and rawmaterialid but it is also loading the old qty instead of the newData
ASKER CERTIFIED SOLUTION
Avatar of HainKurt
HainKurt
Flag of Canada 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
Avatar of Zolf

ASKER

Thanks a lot.
welcome...