My sample payload is given below:
{
"ID": "72a6dcc0",
"SourceCode": "ABC",
"TargetCode": "DEF",
.
.
.
.
.
"Products": [
{
"ProdId": "410ef294",
"ProdDetails": {
"ProdIdentifier": "410ef294-e80b",
"DateFrom": "2019-01-01T00:00:00Z",
"DateTo": "9999-12-31T00:00:00Z",
"ProductName": "ProdA"
}
}
]
}
I need to add a new attribute called "ProdDescription" to the "Products" array so that my output looks like this:
{
"ID": "72a6dcc0",
"SourceCode": "ABC",
"TargetCode": "DEF",
.
.
.
.
.
"Products": [
{
"ProdId": "410ef294",
"ProdDetails": {
"ProdIdentifier": "410ef294-e80b",
"DateFrom": "2019-01-01T00:00:00Z",
"DateTo": "9999-12-31T00:00:00Z",
"ProductName": "ProdA",
"ProdDescription": "This is a Sample"
}
}
]
}
The payload that I have given is only a sample and it has hundreds of attributes. I only need to add a new attributes to the "Products" array and also retain the other items in the main payload. Is it possible to do a complete payload "map" and inside add a new attribute to an array using "mapobject"? I am on dataweave 1.0