Refer to the payload: [{ "orderID": 592, "shipping": "international", "city": "Tokyo" }, {"orderID": 972, "shipping": "domestic", "city": "Cleveland" }]. Which MEL expression accesses the city Cleveland?

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

Refer to the payload: [{ "orderID": 592, "shipping": "international", "city": "Tokyo" }, {"orderID": 972, "shipping": "domestic", "city": "Cleveland" }]. Which MEL expression accesses the city Cleveland?

Explanation:
Accessing a value from an array by its position in MEL uses square brackets after the array reference, then the property you want. The payload is an array with two objects, and the Cleveland city is in the second object (arrays are zero-based, so index 1). So you go to the second element and read its city: that is message.payload[1].city, wrapped in MEL syntax as #[message.payload[1].city], which yields "Cleveland". The other forms would return different data or fail: indexing [0] would give Tokyo, indexing [2] would be out of bounds, and referencing payload without the message context is less explicit and may not resolve correctly in all contexts.

Accessing a value from an array by its position in MEL uses square brackets after the array reference, then the property you want. The payload is an array with two objects, and the Cleveland city is in the second object (arrays are zero-based, so index 1). So you go to the second element and read its city: that is message.payload[1].city, wrapped in MEL syntax as #[message.payload[1].city], which yields "Cleveland".

The other forms would return different data or fail: indexing [0] would give Tokyo, indexing [2] would be out of bounds, and referencing payload without the message context is less explicit and may not resolve correctly in all contexts.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy