MCD-LEVEL-1 practice question 18 of 30

What is the correct syntax for a Logger component to output a message with the contents of a 3SON Object payload?

Full set: 235 questions
Answer options
A: The payload is: $(payload)
B: #["The payload is: " ++ payload]
C: The payload is: #[payload] Correct answer
D: #["The payload is: " + payload]
Correct Answer:
C. The payload is: #[payload]
Explanation

In Mule 4, you can mix literal strings and DataWeave expressions in a component's property field (like a Logger's message field). The syntax The payload is: #[payload] correctly evaluates the DataWeave expression #[payload] and concatenates its string representation with the literal string "The payload is: ".

Why Incorrect

A: $(payload) is DataWeave string interpolation syntax, but it must be enclosed within a DataWeave expression block #[...] to be evaluated. B: Using the ++ operator to concatenate a String and an Object directly in DataWeave 2.0 throws a type mismatch error unless the Object is explicitly coerced to a String. D: The + operator is not used for string concatenation in DataWeave 2.0; ++ is the correct operator.

References

- MuleSoft Documentation, "DataWeave Language", Section: String Interpolation and Concatenation.

Scroll to Top