How to declare function in dataweave?

HariNadh NeTha
HariNadh NeTha

Posted On: Dec 17, 2020

 

You can declare a function in the header or body of a DataWeave script by using the fun keyword.

Declaration of a function in data weave is as follows:

fun function_Name(objParameter) = { 
Variable1: objParameter.field1, 
Variable2: objParameter.field2 
} 

You can simply Invoke the function by using functionName() or functionName(arg1, arg2, argN).

    Related Questions

    Please Login or Register to leave a response.

    Related Questions

    Cognizant Mulesoft interview questions

    What is Singleton pattern?

    The singleton pattern is the simplest design pattern that restricts the one instantiation of a class that involves only one object that is responsible to make sure there is no more than one instance. ...

    Cognizant Mulesoft interview questions

    What is serialization and deserialization in Java?

    In Java, serialization is a mechanism to persist java objects in a form of a sequence of bytes that includes the object’s data as well as information about the object’s type and its value....

    Cognizant Mulesoft interview questions

    What is a middleware?

    Middleware is software that acts as an intermediary between an operating system and software applications, especially on a network. Middleware is generally used for linking various software applicatio...