I am using typescript, I have an existing JSON response below coming through an API,
{
"product":{
"prodId": "PROD100"
},
"packages":{
"pkgId": "PKG137"
},
"discount":"50",
"periodFrom":null,
"periodTo":null,
"totalAmount": "599",
"isActive": "false"
}
I have another small JSON, which I want to append at the top of it
"customer":{
"custId":"CUST1002"
},
Final Structure:
{
"customer":{
"custId":"1002"
},
"product":{
"prodId": "PROD100"
},
"packages":{
"pkgId": "PKG137"
},
"discount":"50",
"periodFrom":null,
"periodTo":null,
"totalAmount": "599",
"isActive": "false"
}
How do I achieve the same using push
or unshift
, or is there any best practice for the same in JavaScript or in typescript. Kindly suggest me