1 / 7

Get started with MuleSoft Dataweave and preferred steps

Mulesoft Dataweave accesses and transforms the Mule app's data, wherein it is an expression language of Mulesoft. It suggests a specific combination of scripts and expressions in the Mule runtime engine of your App. Mulesoft Dataweave expressions pretend like an event in Mule data. Generally, in the message payload, Mulesoft helps to access and transform that data

bhanu2149
Download Presentation

Get started with MuleSoft Dataweave and preferred steps

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Get started with MuleSoft Dataweave and preferred steps Get started with MuleSoft Dataweave and preferred steps Mulesoft Dataweave accesses and transforms the Mule app's data, wherein it is an expression language of Mulesoft. It suggests a specific combination of scripts and expressions in the Mule runtime engine of your App. Mulesoft Dataweave expressions pretend like an event in Mule data. Generally, in the message payload, Mulesoft helps to access and transform that data. Ex: After you retrieve data of components from a system, Dataweave helps you access and transforms the selected data as output and creates a new format. Similarly, choose another part to send the data to another system. Mulesoft DataWeave is the MuleSoft expression language for remodeling knowledge because it travels through a Mule application. There are several real-life use cases where DataWeave will want to take one piece of knowledge and convert it into a particular output format by adding or removing values. Their area unit such a lot of entirely different transformations you will be able to do with Mulesoft DataWeave. Mulesoft DataWeave scripts area unit is divided into two main sections, the header, and therefore the body. The title defines directives that apply to the body, and consequently, the body contains the associate expression that returns the associate output. The header is higher than the body delimiter that consists of 3 dashes --- something more elevated than the three dashes is that the title, and something below the three dashes, is that the body. As you will see within the higher than example, the output can solely come from the message string rather than the complete input JSON payload. It tends to outline the DataWeave script to output payload.message. This output is currently accessible within the remainder of the flow. Variables Variables In DataWeave, there are global and local variables. Global variables were created within the DataWeave script's header and documented anywhere within that script's body. Local variables are made within the script's body and might report among the scope to initialize.

  2. The variable initiates within the header and might access and employ it in the script's body. Below is an Associate in Nursing example of a worldwide variable wherever we tend to concatenate the string and add text once the corporate payload. Functions: Functions: ●In Mulesoft DataWeave, you will produce functions that situate within the header section of your script. Functions are FUN in DataWeave. ●Build your initial operation by the victimization of the fun declaration within your script's header. We glance for the payload to be up to MuleSoft, and if valid, come to the string Match. In the script below, observe, we tend to use the do statement to form a scope in our operation. The information permits new variables, functions, namespaces, and annotations to create inside the area. The section subdivides into the header and body with the three dashes --- as incontestable below.

  3. Match: The match operates permits you to match a string then come to the ends in an array. If you have ever used Java before, the match operates and uses an equivalent library to permit pattern matching on strings. Within the example below, we tend to use the literal match case to output "Match" if the payload. Company string is up to "MuleSoft Dataweave." within the script, it will notice a dollar sign on the else statement. One dollar sign employs for accessing the worth of gone operations. It conjointly replaces the dollar sign with arg (in this use-case), and the output can have an equivalent result. 3 completely different operators are scripts: $ (value), $$ (key), and $$ (index). Import libraries: Import libraries: In Mulesoft DataWeave, there are multiple modules on the market for import lists on the MuleSoft Documentation. This wide range of modules will do tasks like string manipulation, computer address encryption, date data formatting, and lots of additional. To look at the list of available libraries, look at the link higher than the tutorial series can show several additional in- depth. To import a library, merely embrace the import script within your DataWeave Script header section, as shown below. The below scripts encodes the computer address so that the

  4. departing request is valid. MIME types: MIME types: Many information transformations require completely different input and output necessities. To support these completely different scans and write formats, it will be able to specify the MIME sort for each the input and the output information that flows through the Mule application. To vary the MIME sort, set the kind within the header, as shown below. Within the examples below, observe the variations in output vs. application/JSON and text/plain. Dynamic elements: Dynamic elements:

  5. ●In Mulesoft DataWeave, there are multiple instances wherever you will get to output a listing of parts from AN array; however, they do not support the index. ●We have special syntax called dynamic parts that permit you to feature AN expression's results key-value try of “AN” object. ●Tends to come back all of the entries within the array that match the string within the conditional. ●First, we tend to decide the array by payload.entries, and then within the sq. brackets, we tend to use the filter selector outlined by the punctuation mark, which searches through AN array or object for all key-value pairs. ●The condition outlines a 'dollar sign' followed by a single value that can come back to its corresponding key. ●The greenback sign variable permits the code to realize access to every item within the array. Map: Map: ●A map is one of the main used functions in DataWeave and helps integration developers perform complicated transformations that are antecedently challenging. ●The map performs in DataWeave is employed once we wish to change parts in the associate array and perform a series of tasks on every entry. ●The map primarily transforms one payload into another format that is desired by the target end. One critical thought is that the map perform is not modifying the array. ●It is making a replacement array from the specifications that you outline within the map perform. Nothing in DataWeave gets mute, which means that it cannot be modified once more once a particular component form.

  6. ●Let us examine the map that performs works on the main basic level by looking for the instance below. So, we tend to line the map perform on an information kind structured as an associate array as for the map command to figure. ●The input is formatted in JSON, and also the knowledge wraps in an associate array. Once the map command runs on the input, we tend to specify that we wish a Full Name field rather than a separate FirstName and LastName field. ●We tend to map the payload by specifying the specified output format in our DataWeave script to realize this transformation. Mapping victimization selectors: Mapping victimization selectors: The sample input file has all of its parts listed below account type, wherever there square measure two sub-sections, users and admins. Within each of those arrays is user info, which incorporates the person's Name and Company. The goal is to list the information below the user's array, which can remap below the account Info array solely. ●We tend to initiate by shaping that we wish to map the payload—accountType array to achieve this transformation. ●We tend to use a multi-selector then, the significance by *users, that employs to run the map command on entries matching with the name users. ●In DataWeave, you will represent the index count by employing a double greenback sign $ and may represent the component with one greenback sign $. ●We tend to use the one greenback sign to list out the weather in every object during this example.

  7. Conclusion: Conclusion: This article solely lined the terrible basics of Mulesoft DataWeave. Click here to continue reading this series to map objects and make information transformations in DataWeave. If you want to learn more follow to Mulesoft Online Training.

More Related