Mulesoft Dataweave Interview Questions and Answers
Dataweave Interview questions for Mulesoft interviews. Dataweave 1.0 and Dataweave 2.0 for Mule 3 and Mule 4. Dataweave is the replacement for MEL Mule Expression Language in Mule 3. In Mule 4 DataWeave version has changed from 1.0 to 2.0. Let us discuss the top & most frequently asked MuleSoft Interview questions in Top MNCs in 2021.Dataweave Interview questions for Mulesoft in 2021
What is the use of reduce operator in Dataweave?
It performs an aggregation operation on an array of elements
What is the use of groupBy, orderBy & splitBy operators in Dataweave?
groupBy: Returns an object that groups items from an array based on specified criteria, such as an expression or matching selector.
orderBy: Reorders the elements of input using criteria that act on selected elements of that input.
splitBy: Splits a string into a string array based on a value that matches part of that string. It filters out the matching part from the returned array.
How do you fetch the keys from the key-value pair of an object?
keysOf function: Returns an array of keys from key-value pairs within the input object.
How do you fetch the values from the key-value pair of an object?
valuesOf function: Returns an array of the values from key-value pairs in an object.
How can we update specific fields of an object using the Dataweave operator?
update operator: DataWeave supports the update operator, which enables you to update specified fields of a data structure with new values.
Differences between DW1.0 & DW2.0
Few of the changes from Dataweave 1.0 of Mule 3 to Dataweave 2.0 of Mule 4
- Header Changes,
- Conditional Logic
- Operators are functions
- Type Names
- Comments
What is the p function in Dataweave?
p function is used for reading data from properties file in transform message generally we use "p" function.
What is the lookup function in Dataweave?
lookup is used to invoke flows from Dataweave code
What is a causedBy function in Dataweave?
The causedBy function matches an error by its type as an error handler does
What is the difference between map, mapObject, and pluck?
- map is used to iterate over an array
- mapObject is used to iterate over the object and return the object
- pluck iterates over an object and returns an array of keys, values, or indices in that object.
Difference between Map, flatMap, and MapObject?
Map: Iterates over items in an array and outputs the results into a new array.
FlatMap: Iterates over each item in an array and flattens the results.
MapObject: Iterates over an object using a mapper that acts on keys, values, or indices of that object.
How do you import a module into Dataweave code?
Specify the import directive in the header along with the module's name
How to convert an Object into an Array using Dataweave?
Pluck - Iterates over an object and returns an array of keys, values, or indices from the object
How to access secure property inside Dataweave?By using p(secure::<property name>) you can access the secure property defined as part of the secure property file in the mule application
I have an array within it I have a nested array of data, how can I make a simple array?
Flatten - Turns a nested array into a simple array
How will you combine 2 arrays into a single array is MuleSoft?
You can use flatten Dataweave function to combine two arrays into single array
Difference between flatMap and flatten?
flatMap: Iterates over each item in an array and flattens the results, can act on values and indices of items in the array.
Flatten - Turns a nested array into a simple array. only acts on the values of the arrays
How can you do Type coercion in Dataweave?
In DataWeave, types can be coerced from one type to another using the as operator. Type coercion takes place at runtime
How to call Flow from inside a Dataweave?
You can use Dataweave lookup function to call flow from inside a Dataweave It works in Mule apps that are running on Mule Runtime version 4.1.4 and later It takes the flow’s name and an input payload as parameters. For example, lookup(“flowname”, payload)
Find the latest MuleSoft(Mule 4) Articles on DataWeave, Anypoint Studio, Anypoint Platform, and Runtime Manager. Our articles also include frequently asked Mule4 Interview questions and answers. Please comment below for any queries or free article submissions.
0 Comments