Gorodeckij Dimitrij
Gorodeckij Dimitrij

Reputation: 4636

Mule esb 3.8 how to add object variable (HashMap) into payload (HashMap)

Hello need a bit of help to understand how I can merge 2 payloads from db calls into one - final payload.

First payload is like:

[{Name=John, Age=31}]

Second payload is like:

Address=[{Planet=Earth, Continent=Europa, Town=London},{Planet=Earth, Continent=Europa, Town=Dublin}]

Final result I am expecting as such:

[{Name=John, Age=31, Address=[{Planet=Earth, Continent=Europa, Town=London},{Planet=Earth, Continent=Europa, Town=Dublin}]}]

I was try ++ and putAll but its not happy and don't allow me to do it, preferable without dw. Technically I understand that its need to add but cant find right syntactic and help is not helpful for such :(

Thanks in advance.

Upvotes: 0

Views: 150

Answers (1)

Harshank Bansal
Harshank Bansal

Reputation: 3262

Your payload is an ArrayList of HashMap, not a HashMap. Similarly your flowVars.Address is also a List. For adding it in the first HashMap of your payload you can try the following

<expression-component doc:name="Expression"><![CDATA[#[payload.get(0).put("Address", flowVars.Address)]]]></expression-component>

Upvotes: 1

Related Questions