To transform XML to JSON in DataWeave 2.0, which script setup is correct?

Prepare for the MuleSoft Developer 2 Certification Exam. Access practice quizzes featuring flashcards and multiple choice questions with explanations. Get confident and ready for your certification success!

Multiple Choice

To transform XML to JSON in DataWeave 2.0, which script setup is correct?

Explanation:
Transforming data formats in DataWeave hinges on declaring what you’re reading and what you’re producing. For Mule 4, using DataWeave 2.0, converting XML to JSON means the script should read XML input and emit JSON output. Specifying the DataWeave version as 2.0 and setting the output to application/json signals DataWeave to parse the incoming XML (application/xml) and produce JSON. The payload expression then yields the transformed JSON representation of the XML input. This setup matches the requested direction—XML to JSON—and uses the correct DataWeave version for Mule 4. The other options either reverse the transformation, rely on the older DataWeave 1.0, or specify an unsuitable input type like text/plain.

Transforming data formats in DataWeave hinges on declaring what you’re reading and what you’re producing. For Mule 4, using DataWeave 2.0, converting XML to JSON means the script should read XML input and emit JSON output. Specifying the DataWeave version as 2.0 and setting the output to application/json signals DataWeave to parse the incoming XML (application/xml) and produce JSON. The payload expression then yields the transformed JSON representation of the XML input. This setup matches the requested direction—XML to JSON—and uses the correct DataWeave version for Mule 4. The other options either reverse the transformation, rely on the older DataWeave 1.0, or specify an unsuitable input type like text/plain.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy