fbpx

Dataweave Interview Question: Combine Country and Capital Name From Input


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!



Source link

Leave a Reply

Shopping cart

0
image/svg+xml

No products in the cart.

Continue Shopping