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
Over 2 million developers have joined DZone.
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

  • How to Save Money Using Custom LLMs for Specific Tasks
  • Agentic Testing: Moving Quality From Checkpoint to Control Layer
  • From 24 Hours to 2 Hours: How We Fixed a Broken BI System With Apache Airflow
  • How to Interpret the Number of Spring ApplicationContexts in Integration Tests
  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 user avatar
Gaurav Dubey
·
Jan. 21, 22 · Code Snippet
Likes (2)
Comment
Save
Tweet
Share
6.4K Views

Join the DZone community and get the full member experience.

Join For Free

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

The likes didn't load as expected. Please refresh the page and try again.

  • 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