Closed kensowens closed 3 years ago
Hi @kensowens ,
Would be good if you could share the sample input for the Mulesoft dw expression you have mentioned in your question.
I am assuming that you are trying to use a sample payload as given below.
{ "msg": { "payload": [ { "CHARGEOFFAMOUNT": 273, "DATEREPORTED": "08-20-2021" }, { "CHARGEOFFAMOUNT": 40, "DATEREPORTED": "02-02-2021" }, { "CHARGEOFFAMOUNT": 360, "DATEREPORTED": "03-01-2020" }, { "CHARGEOFFAMOUNT": 150, "DATEREPORTED": "08-08-2021" } ] } }
Note: In the above example, the content is wrapped under msg.payload object. This is just for example .
The datamapping in Kumologica will be as follows:
$map(msg.payload,function($v,$i,$a){ { "chargeOffAmount" : $v.CHARGEOFFAMOUNT, "Date": $v.DATEREPORTED } })
If you want only the first index then use the datamapping in the following way.
$map(msg.payload,function($v,$i,$a){ { "chargeOffAmount" : $v.CHARGEOFFAMOUNT[0], "Date": $v.DATEREPORTED[0] } })
I hope that answers your question. Going forward would be really helpful if you could to share sample payload and expected output for such scenarios so that we could provide precise mapping expression and avoid the round trip.
The above sample is available on the following JSONata exerciser : https://try.jsonata.org/Bk444a_58
Thank You this solved my issue. I will include examples next time.
Hello I have this code in Mulesoft. How would I convert this to Kumologica?
%dw 2.0 output application/json
payload map (value, index) -> { "chargeOffAmount" : value.CHARGEOFFAMOUNT[0], "Date": value.DATEREPORTED[0]}
Thanks for your help Kenny