This article will help you practice your DataWeave skills in MuleSoft. Today, we’ll learn to combine the country and capital name from the input by using the map function.Â
Let’s get started.Â
Input:
[
{
"Capital":Â "New Delhi",
"Country":Â "India"
},
{
"Capital":Â "Paris",
"Country":Â "France"
}
]
Output:
[
 "India-New Delhi",
 "France-Paris"
]
We will achieve the desired output in a single step by using the map function.
Output Code:
DataWeave Script
%dw 2.0
output application/json
---
payload map ($.Country ++ "-" ++ $.Capital)
Happy Learning!