Dataweave Interview Question: Combine Country and Capital Name From Input
This article will help you practice your DataWeave skills in MuleSoft. Use this article as a tutorial for learning more about DataWeave.
Join the DZone community and get the full member experience.
Join For FreeThis 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:
JSON
[
{
"Capital": "New Delhi",
"Country": "India"
},
{
"Capital": "Paris",
"Country": "France"
}
]
Output:
JSON
[
"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!
Capitals (typeface)
Interview (journalism)
Opinions expressed by DZone contributors are their own.
Comments