Contact Us 1-800-596-4880

Core Types (dw::Core)

DataWeave 2.1 is compatible with Mule 4.1. Standard Support for Mule 4.1 ended on November 2, 2020, and this version of Mule will reach its End of Life on November 2, 2022, when Extended Support ends.

Deployments of new applications to CloudHub that use this version of Mule are no longer allowed. Only in-place updates to applications are permitted.

MuleSoft recommends that you upgrade to the latest version of Mule 4 that is in Standard Support so that your applications run with the latest fixes and security enhancements.

Type Definition Description

Any

type Any = Any

The top-level type. Any extends all of the system types, which means that anything can be assigned to a Any typed variable.

Array

type Array = Array

Array type that requires a Type(T) to represent the elements of the list. Example: Array<Number> represents an array of numbers, and Array<Any> represents an array of any type.

Binary

type Binary = Binary

A blob.

Boolean

type Boolean = Boolean

A Boolean type of true or false.

CData

type CData = String {cdata: true}

XML defines a CData custom type that extends from String and is used to identify a CDATA XML block.

It can be used to tell the writer to wrap the content inside CDATA or to check if the input string arrives inside a CDATA block. :cdata inherits from the type :string.

Source

%dw 2.0
output application/xml
---
{
  "users" :
  {
    "user" : "Mariano" as CData,
    "age" : 31 as CData
  }
}

Output

<?xml version="1.0" encoding="UTF-8"?>
<users>
  <user><![CDATA[Mariano]]></user>
  <age><![CDATA[31]]></age>
</users>

Comparable

type Comparable = String | Number | Boolean | DateTime | LocalDateTime | Date | LocalTime | Time | TimeZone

A union type that represents all the types that can be compared to each other.

Date

type Date = Date

A date represented by a year, month, and day. For example: |2018-09-17|

DateTime

type DateTime = DateTime

A Date and Time within a TimeZone. For example: |2018-09-17T22:13:00Z|

Dictionary

type Dictionary = { _?: T }

Generic dictionary interface.

Enum

type Enum = String {enumeration: true}

This type is based on the Enum Java class.

It must always be used with the class property, specifying the full Java class name of the class, as shown in the example below.

Source

%dw 2.0
output application/java
---
"Male" as Enum {class: "com.acme.GenderEnum"}

Iterator

type Iterator = Array {iterator: true}

This type is based on the iterator Java class. The iterator contains a collection and includes methods to iterate through and filter it.

Just like the Java class, Iterator is designed to be consumed only once. For example, if you pass it to a Logger component, the Logger consumes it, so it becomes unreadable by further elements in the flow.

Key

type Key = Key

A key of an Object.

LocalDateTime

type LocalDateTime = LocalDateTime

A DateTime in the current TimeZone. For example: |2018-09-17T22:13:00|

LocalTime

type LocalTime = LocalTime

A Time in the current TimeZone. For example: |22:10:18|

NaN

type NaN = Null {NaN: true}

java.lang.Float and java.lang.Double have special cases for NaN and Infinit. DataWeave does not have these concepts for its number multi-precision nature. So when it is mapped to DataWeave values, it is wrapped in a Null with a Schema marker.

Namespace

type Namespace = Namespace

A Namespace type represented by a URI and a prefix.

Nothing

type Nothing = Nothing

Bottom type. This type can be assigned to all the types.

Null

type Null = Null

A Null type.

Number

type Number = Number

A number type: Any number, decimal, or integer is represented by the Number` type.

Object

type Object = Object

Type that represents any object, which is a collection of Key and value pairs.

Period

type Period = Period

A period.

Range

type Range = Range

A Range type represents a sequence of numbers.

Regex

type Regex = Regex

A regex type.

SimpleType

type SimpleType = String | Boolean | Number | DateTime | LocalDateTime | Date | LocalTime | Time | TimeZone | Period

A union type that represents all the simple types.

String

type String = String

These are the native types of DataWeave.

They are the only types that allow the ??? definition.

Time

type Time = Time

A time in a specific TimeZone. For example: |22:10:18Z|

TimeZone

type TimeZone = TimeZone

A time zone.

Type

type Type = Type

A type in the DataWeave type system.

Uri

type Uri = Uri

A URI.