DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Mastering React: Common Interview Questions and Answers
  • Probing Questions for Your Interview
  • Interviews from the ALM Forum: Like SETI@home, but For Your Builds
  • TypeScript Interview Questions and Answers

Trending

  • AI Didn't Replace Software Engineering; It Changed the Bottleneck
  • Detecting Duplicates With Machine Learning in 2026: From String Metrics to Embeddings and LLMs
  • Designing a Data Pipeline for Multi-Location Marketing Attribution (Before You Actually Need One)
  • Top Gen AI Frameworks for Go in 2026: A Hands-on Comparison

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  1. DZone
  2. Culture and Methodologies
  3. Career Development
  4. Dataweave Interview Question: Combine Country and Capital Name From Input

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.

By 
Gaurav Dubey
·
Jan. 21, 22 · Code Snippet
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
6.6K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

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:

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.

Related

  • Mastering React: Common Interview Questions and Answers
  • Probing Questions for Your Interview
  • Interviews from the ALM Forum: Like SETI@home, but For Your Builds
  • TypeScript Interview Questions and Answers

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook