---
schema_version: "1"
id: de8daf66917dc94e97258b4b7a8762e7f613a35d8aa001ea729f48354ddc6f8c
title: "Introduction to Mule 4: DataWeave 2.0"
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/mule-runtime/4.3/intro-dataweave2.md
canonical_url: https://docs.mulesoft.com/mule-runtime/4.3/intro-dataweave2
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 6d6d6329e481afcabd50fc56814091083469d16ec15868deffc55221ba7dc3f1
description: MuleSoft Documentation Site
release: "4.3"
latest: false
---
---
product: Mule Runtime
version: 4.3
---

# Introduction to Mule 4: DataWeave 2.0

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

DataWeave 2 is largely unchanged from DataWeave 1. However, MuleSoft made many improvements to make
it easier to learn and added new capabilities.

## Operators Are Functions

In DataWeave 2, all operators are now functions. While this can involve more parentheses, it is less
ambiguous and more friendly to learn through auto-completion features. The previous syntax continues
to work for functions with two parameters, providing a shorter syntax for power users.

<table><colgroup><col> <col> <col></colgroup><tbody><tr><td><p>DataWeave 1</p></td><td><p><code>sizeOf payload filter $.age &gt; 30</code></p></td><td></td></tr><tr><td><p>DataWeave 2 - Function Syntax</p></td><td><p><code>sizeOf(filter(payload, (value) → value.age &gt; 30)))</code></p></td><td></td></tr><tr><td><p>DataWeave 2 - Shortcut Syntax</p></td><td><p><code>sizeOf(payload filter $.age &gt; 30)</code></p></td><td></td></tr></tbody></table>

## Traits Are Functions

<table><colgroup><col> <col> <col></colgroup><tbody><tr><td><p>DataWeave 1</p></td><td><p><code>payload is :empty</code></p></td><td></td></tr><tr><td><p>DataWeave 2</p></td><td><p><code>isEmpty(payload)</code></p></td><td></td></tr></tbody></table>

## Type Names

DataWeave 2 uses a type name syntax, which removes the `:` from the name.

<table><colgroup><col> <col> <col></colgroup><tbody><tr><td><p>DataWeave 1</p></td><td><p><code>payload.foo as :string</code></p></td><td></td></tr><tr><td><p>DataWeave 2</p></td><td><p><code>payload.foo as String</code></p></td><td></td></tr></tbody></table>

## XML Format

The default for the reader property `nullValueOn` is `empty` for DataWeave 2.0.

For DataWeave 1.0 (which is compatible with Mule 3.x), the value is `none`, for example:

DataWeave Script

```dataweave
%dw 1.0
%output application/xml nullValueOn="none"
---
payload
```

Input

```xml
<book>
  <name></name>
</book>
```

Output

```xml
<book/>
```

## New Capabilities

There are also many new capabilities, including:

- Typing for reusable functions

- Multi-line comments

- Ability to call out to Java code

- Multipart, URL-encoded, and text readers and writers

- Modules and imports

- and more

## See Also

[Migrating from DataWeave 1.0 to 2.x](https://docs.mulesoft.com/mule-runtime/4.3/migration-dataweave)

[DataWeave Language](https://docs.mulesoft.com/mule-runtime/4.3/dataweave)
