---
schema_version: "1"
id: 486d8cb0aa25e9cf94f9f45260119d3c499a31180838b7d3c1be8371c4698b32
title: Mule Data Types
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/mule-runtime/4.6/mule-data-types.md
canonical_url: https://docs.mulesoft.com/mule-runtime/4.6/mule-data-types
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 9ee0028f4d0b185d49f05118faf25646ad10f4928b0cfcff23acf58db5c19da7
description: MuleSoft Documentation Site
release: "4.6"
latest: false
---
---
product: Mule Runtime
version: 4.6
---

# Mule Data Types

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

Mule runtime engine uses a typed data structure called `TypedValue` that centralizes data access
across different components. This data structure provides access to both the actual data and its
data type. The data type consists of two values, the MIME type and the encoding of the data.

## Input Data

Mule stores all variables and the payload using the `TypedValue` data structure. Also, operations
like `List` from the Anypoint Platform File Connector return their results as `TypedValue`
instances, enabling DataWeave to list different types of files (JSON, XML, CSV, and so on) to read.

## Output Data

DataWeave always outputs a `TypedValue` instance. DataWeave decides what writer to use based on the
data type of the `TypedValue` instance. However, you can manually specify the data type in a
DataWeave script by using the `output` directive. If the script that Mule is executing is assigned
to a message processing field, Mule informs DataWeave which type of data to expect type based on the
metadata of that field. For example, if the data type is a Plain Old Java Object (Pojo), then
DataWeave knows not only which class to instantiate but also that it must use the Java writer to
generate the output.

## How DataWeave Uses Mule Data Types

DataWeave uses the data type contained in the `TypedValue` instance to determine which reader to
use, based on the MIME type, and how to configure that reader (encoding, reader properties), based
on the MIME type properties. When DataWeave cannot determine the data type, it follows this
procedure:

1.  Verifies which input types the script is using.

    If all inputs are compatible or of the same data type, DataWeave uses that data type. For
    example, if the script contains `<set-payload value="#[payload.someValue]/>` DataWeave examines
    the data type of the payload and, if the payload is JSON, DataWeave uses the JSON writer. If
    there is more than one input in the script and they are from different data types, DataWeave
    throws an error.

    For example, if the script contains `<set-payload value="#[payload.someValue ++ vars.myVar]/>`,
    in which `vars.myBar` is of type XML and `payload` is of type JSON, DataWeave throws an error.
    In some cases, specifically when working with XML, an expression in a Set payload operation
    fails because it generates an invalid XML structure.

2.  If no input is used, DataWeave uses the Java writer.

    For example, when DataWeave reads the script `<set-payload value="#[\{a: true}]/>`, it uses the
    Java writer to output a `java.util.Map` object with an entry containing ("a", true).

    For the Logger message processor, DataWeave has a special feature to avoid errors when creating
    the output. First, DataWeave tries to determine which input types the script is using, and then
    it uses the corresponding writer to generate the output. If DataWeave fails because the writer
    cannot create that data structure, then DataWeave uses the DataWeave writer, which can output
    any possible data structure.

## See Also

- [DataWeave Language](https://docs.mulesoft.com/dataweave/latest/)

- [Setting MIME Types in DataWeave](https://docs.mulesoft.com/dataweave/latest/dataweave-formats#setting-mime-types)
