Using the below input trying to generate the desired output, condition based in the array of values is not working. can you provide some inputs on this. Based on customer and promotion type need to append the amount values
{
"Id": "100",
"name": "Test",
"discounts": [
{
"TypeCode": "customer",
"Amount": 20
},
{
"TypeCode": "promotion",
"Amount": 10
}
],
"items": [
{
"LineId": "1001",
"lineItem": "TestProduct",
"discountDetails": [
{
"LineTypeCode": "customer",
"discountAmount": 300
},
{
"LineTypeCode": "customer",
"discountAmount": 330
}
]
}
]
}
Desired output format :
{
"Id": "100",
"name": "Test",
customerAmount : 20,
promotionAmount : 10,
"items": [
{
"LineId": "1001",
"lineItem": "TestProduct",
"customerlineamount" : 300,
"foclineamount" : 330
}
]
}