How to add additional object inside array in dataweave. Please find the input and expected response. I stored the below input in flowVars
Input:
{
"calculate": [{
"rate": 10.4500,
"margin": 0.000,
"amount": 1000
}]
}
If the input amount is greater than 1000, add additional one more object along with the original one. Response should look like below
Response:
{
"calculate": [{
"actualRate": 10.4500,
"amount": 1000
},
{
"actualRate": 10.4500,
"amount": null
}]
}
Dataweave: (not sure how to add extra object in the response above)
%dw 1.0
%output application/java
---
{
calculate: flowVars.calculate map {
actualRate:$.rate,
amount:$.amount
}
}
Could anyone can help me with this. Thanks in advance.