Mule 3.8.3 Studio 6.4.4
I am receiving a XML payload that is a collection of customer numbers. I need to end up pulling each number out and sending it to a messaging queue.
Sample Incoming Data:
<request func="">
<data>
<transactions time='1539262470'>
<transaction set='customers' notifyid='WMS_NADC_CUSTOMERS' type='update'>
<customers>
<customer id="CIT_1113-11" t="1539257721" y="U" w="WebUser"></customer>
<customer id="C42998-2" t="1539261561" y="N" w="WebUser"></customer>
<customer id="C42998" t="1539262040" y="U" w="WebUser"> </customer>
</customers>
</transaction>
</transactions>
</data>
</request>
After receiving this I use weave to transform into json in an attempt to more easily access the id's.
%dw 1.0
%output application/json
---
{
customers: payload.request.data.transactions.transaction.customers.*customer map (cust, indexOfCustomer) ->{
customer: cust.@id as :string
}
}
The transformed payload now looks like
{
"customers": [
{
"customer": "CIT_1113-11"
},
{
"customer": "C42998-2"
},
{
"customer": "C42998"
}
]
}
At this point, I am trying to loop through the payload. Setting the for each to payload.get('customers')
takes me into a jackson.node.ArrayNode.
I haven't been able to figure out how to access each individual object inside the list. Can one of you please tell me how to do that?
I want to end up placing a payload onto a message queue that looks like
{
"customer": "C42998"
}