Dataweave

73 lessons154 min total



  1. What is Dataweave
    DataWeave is a programming language designed for transforming data. It is MuleSoft’s primary language for data transformation, as…


    3 min





  2. MIME TYPES in DataWeave 2.0
    DataWeave can read and write many types of data formats, such as JSON, XML, CSV, XSLS and many…


    2 min





  3. AVRO FORMAT
    Avro is a row-based storage format for Hadoop, which is widely used as a serialization platform.


    1 min





  4. CSV FILE FORMAT
    A comma-separated values (CSV) file is a delimited text file that uses a comma to separate values. Each…


    2 min





  5. DataWeave Format
    The DataWeave (dw) format is the canonical format for all transformations. This format can help you understand how…


    2 min





  6. Flat File Format
    A flat-file database is a database stored in a file called a flat file. Records follow a uniform…


    3 min





  7. JAVA Format
    The java string format() method returns the formatted string by given locale, format and arguments. If you don't…


    1 min





  8. Json Format
    JSON (JavaScript Object Notation, pronounced /ˈdʒeɪsən/; also /ˈdʒeɪˌsɒn/) is an open standard file format and data interchange format…


    6 min





  9. Binary Format
    Binary format means that the sign (positive or negative) is in the leftmost bit of the field and…


    2 min





  10. Excel Format
    When we format cells in Excel, we change the appearance of a number without changing the number itself.…


    6 min





  11. XML Format
    The Extensible Markup Language (XML) is a simple text-based format for representing structured information: documents, data, configuration, books,…


    1 min





  12. Newline Delimited json Format
    NDJSON is a convenient format for storing or streaming structured data that may be processed one record at…


    3 min





  13. URL Encoded Format
    URL encoding converts non-ASCII characters into a format that can be transmitted over the Internet. URL encoding replaces…


    4 min





  14. YAML Format
    YAML is a data serialization language that is often used for writing configuration files. Depending on whom you…


    2 min





  15. Multipart Format (Form Data)
    DataWeave supports Multipart subtypes, in particular form-data. These formats enable you to handle several different data parts in…


    4 min





  16. Text Plain Format
    The simplest way to store information in computer memory is as a single file with a plain text…


    11 min





  17. Text Java Properties Format
    The Text Java Properties format parses any Java properties file. This format represents simple key-value pairs. DataWeave represents…


    6 min





  18. SCRIPT ANATOMY
    Notice in the script that there are three lines, a line with three dashes, then one more line.…


    2 min





  19. Creating Data
    As you'd expect, the last two are actually composite types, their contents also have type definitions:


    7 min





  20. Reading Data
    reading data is just as important, and the features available to do so are just as robust.


    4 min





  21. Single-Value Selector
    The single-value selector (.) allows you to lookup Object values by their key.


    3 min





  22. Multi-Value Selector (.*)
    The multi-value selector (.*) returns an Array containing any value that matches the key. The values returned are…


    2 min





  23. Descendants Selector (..)
    The descendants selector (..) is the perfect tool to use when you need the values for a certain…


    1 min





  24. Key-Value Pair Selector (.&myKey)
    The & selector acts on arrays and objects. & retrieves both the keys and values of all matching…


    1 min





  25. Index Selector ([])
    The index selector returns the element at the specified position. It can be applied over an array, object,…


    3 min





  26. Range selector (anIndex to anotherIndex)
    If you need multiple sequential values from an Array, DataWeave allows you to select a range of values…


    2 min





  27. XML Attribute Selector (.@myKey)
    Using .@ without the key name returns an object containing the attributes as key-value pairs.


    1 min





  28. Namespace Selector (#)
    # returns the XML namespace of a selected key as plain text.


    1 min





  29. Selector Modifiers (!, ?)
    You can check for the presence of a given key. ! evaluates the selection and fails with an…


    1 min





  30. Filter Selectors (myKey[?($ == “aValue”)])
    myKey[?($ == "aValue")] returns only the values of matching keys within an array or object. Note that ?…


    1 min





  31. Metadata Selector (.^someMetadata)
    Returns the value of specified metadata for a Mule payload, variable, or attribute.


    2 min





  32. Content Length Metadata Selector (.^contentLength)
    In the following Mule app flow, the Logger uses payload.^contentLength to select the length of the string my…


    1 min





  33. Class Metadata Selector (.^class)
    Returns the class of the Plain Old Java Object (POJO). The value might result from calling a method…


    1 min





  34. Encoding Metadata Selector (.^encoding)
    In the following Mule app flow, the Logger uses payload.^encoding to select the encoding of "my string"`set in…


    1 min





  35. Media Type Metadata Selector (.^mediaType)
    Returns the MIME type of a value that includes parameters (for example, application/json;charset=UTF-16). The expression in the value…


    2 min





  36. MIME Type Metadata Selector (.^mimeType)
    In the following Mule app flow, the Loggers use payload.^mimeType to select a string "my string", then to…


    1 min





  37. Raw Metadata Selector (.^raw)
    The following example uses the Set Payload component (set-payload) to produce a binary value, then uses the Transform…


    2 min





  38. Custom Metadata Selector (.^myCustomMetadata)
    The following example uses userName.^myCustomMetadata to return the value of custom metadata that is defined as a variable…


    1 min





  39. Scatter-Gather Router
    The Scatter-Gather component is a routing event processor that processes a Mule event through different parallel processing routes…


    5 min





  40. Error Handling in Mule 4
    An exception occurs when an unexpected event happens while processing. Exception (or error) handling is the process of…


    8 min





  41. Variables in DataWeave 2.0 (Mule 4)
    Variables are a way to store values with a given name so they can be later reused from…


    2 min





  42. Global & Local Variables In DataWeave 2.0
    We can create a global variable in the header using var directive. We need to give it a…


    4 min





  43. Logical Operators
    A logical operator is a symbol or word used to connect two or more expressions such that the…


    2 min





  44. Flow Control
    Flow control is used when you want to execute certain parts of your code in some situations, while…


    1 min





  45. if else Condition in Flow Control (DataWeave 2.0)
    An if statement evaluates a conditional expression and returns the value under the if only if the conditional…


    1 min





  46. else if Condition in flow (DataWeave 2.0)
    You can chain several else expressions together within an if-else construct by incorporating else if.


    1 min





  47. do statement in flow control (DataWeave 2.0)
    A do statement creates a scope in which new variables, functions, annotations, or namespaces can be declared and…


    1 min





  48. Pattern Matching with Literal Values
    A match expression contains a list of case statements that can optionally have an else statement. Each case…


    1 min





  49. Functions in DataWeave 2.0
    You can define your own DataWeave functions using the fun declaration in the header of a DataWeave script.


    1 min





  50. Named Functions
    We create functions in the declarations section of the script using the fun keyword. This associates a set…


    1 min





  51. Lambdas Function
    DataWeave provides multiple ways to create functions. Just like we have named functions, we have functions without names,…


    1 min





  52. Functions as Values
    In other words, lambdas become useful when you want to pass functions as arguments to other functions, or…


    1 min





  53. Infix Notation
    This type of notation is referred to as infix since the operator is in between the two operands…


    1 min





  54. $, $$, $$$ Syntax
    For functions that DataWeave provides, you can represent the first, second, and third arguments of the passed lambda…


    1 min





  55. Arrays (dw::core::Arrays)
    DataWeave 2.0 makes it easier to define an array with a range (" to ").


    2 min





  56. The filter Function (and Function Type Signatures) In DataWeave Mule 4
    This function can be applied to an array. It iterates the array and matches the values with the…


    1 min





  57. The map Function In DataWeave Mule 4
    Iterates over items in an array and outputs the results into a new array.


    1 min





  58. The distinctBy Function In DataWeave Mule 4
    This function is useful for when you need to remove duplicate items from an Array.


    1 min





  59. The groupBy Function In DataWeave Mule 4
    This function is useful for grouping together items in an array based on some value that is generated…


    1 min





  60. The reduce Function In DataWeave Mule 4
    Reduce function is used to do any computation while iterating on an array, so the computation result is…


    2 min





  61. Working with Objects
    It processes both keys and values as a tuple.


    1 min





  62. filterObject function in DataWeave 2.0 (mulesoft)
    The filterObjectoperator iterates over a list of key-value pairs in an object and applies an expression that returns…


    1 min





  63. mapObject function in DataWeave 2.0 (mulesoft)
    We use mapObject when we want to change the keys and/or values on an Object to be something…


    1 min





  64. pluck function in DataWeave 2.0 (mulesoft)
    The pluck operator is useful for mapping the object into the array, and it returns the array of…


    1 min





  65. Update Operator
    This operator is the one to use when you wish to change specific fields on an Object, while…


    1 min





  66. Update Operator Examples
    Update Operator Examples


    1 min





  67. Selector Expressions (update Operator)
    Use selector expressions with the update operator to specify the fields to update.


    2 min





  68. flatten function in DataWeave 2.0 (mulesoft)
    With the help of flatten function multiple arrays are bounded together as single array.


    1 min





  69. splitBy function in DataWeave 2.0 (mulesoft)
    Splits a string into a string array based on a value of input or matches part of that…


    2 min





  70. splitBy Examples in DataWeave 2.0
    Helper function that enables splitBy to work with a null value.


    1 min





  71. read function in DataWeave
    Reads a string or binary and returns parsed content. This function can be useful if the reader cannot…


    1 min





  72. readUrl in DataWeave
    ThereadUrlfunction is similar to the read function, but it accepts URL as an input and the remaining parameters…


    1 min





  73. readUrl Example in DataWeave
    readUrl Example


    1 min