In DataWeave 1.0, with output application/xml, the payload { "fname": "John", "lname": "Doe" } is produced. What is the result?

Study for the MuleSoft Associate / Development Fundamental Test. Master key concepts with flashcards and multiple choice questions, complete with hints and explanations. Prepare thoroughly for your exam!

Multiple Choice

In DataWeave 1.0, with output application/xml, the payload { "fname": "John", "lname": "Doe" } is produced. What is the result?

Explanation:
DataWeave 1.0 XML output must have a single root element. The payload you’re starting with is a plain object with two top-level fields, so there’s no root element name to create well-formed XML from. That’s why you’d get an exception unless you wrap the data in a root element, such as user, with fname and lname inside. For example, wrapping yields XML like <user><fname>John</fname><lname>Doe</lname></user>. The other ideas—having a root named John or fname, or placing a JSON string inside an XML tag—don’t produce well-formed XML from a bare map. Wrapping into a root element is the correct approach.

DataWeave 1.0 XML output must have a single root element. The payload you’re starting with is a plain object with two top-level fields, so there’s no root element name to create well-formed XML from. That’s why you’d get an exception unless you wrap the data in a root element, such as user, with fname and lname inside. For example, wrapping yields XML like JohnDoe. The other ideas—having a root named John or fname, or placing a JSON string inside an XML tag—don’t produce well-formed XML from a bare map. Wrapping into a root element is the correct approach.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy