---
schema_version: "1"
id: 8044234694751c6bfa1d30eb3afe099c00e5d5dbfef825a9d1fc2099447c3063
title: Set Reader and Writer Configuration Properties
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.9/dataweave-cookbook-set-reader-writer-props.md
canonical_url: https://docs.mulesoft.com/dataweave/2.9/dataweave-cookbook-set-reader-writer-props
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 764b60c4dfb26a62b2513230de0fac4c8de6e9748dca7e71d79927f1b9b85084
description: MuleSoft Documentation Site
release: "2.9"
latest: false
---
---
product: DataWeave
version: 2.9
keywords: studio, anypoint, transform, transformer, format, dataweave, data weave, output structure, mime type, mime
---

# Set Reader and Writer Configuration Properties

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

DataWeave provides configuration properties for data formats, such as JSON (`application/json`), XML
(`application/xml`), and (`application/csv`). The properties change the behavior of DataWeave
readers and writers for those formats. For example, the default separator for a CSV reader is a
comma (`,`). You can use the format’s `separator` property to specify a different separator for CSV
content.

Refer to [DataWeave Formats](https://docs.mulesoft.com/dataweave/2.9/dataweave-formats) for more details on available reader and writer
properties for various data formats.

## Use a Writer Property in an Output Directive

The following example shows how to append writer properties to the DataWeave `output` directive. The
script uses `indent = false` to compress the JSON output into a single line.

DataWeave Script:

```dataweave
%dw 2.0
output application/json indent = false
---
{
	hello : "world",
	bello : "world",
	mello : "world"
}
```

Output JSON:

```json
{ "hello": "world", "bello": "world", "mello": "world" }
```

The following examples also append writer configuration properties to the `output` directive:

- [Avro example](https://docs.mulesoft.com/dataweave/2.9/dataweave-formats-avro#examples) that uses `schemaUrl`

- [Excel (XLSX) example](https://docs.mulesoft.com/dataweave/2.9/dataweave-formats-excel#example2) that uses `header=true`

- [Flat File](https://docs.mulesoft.com/dataweave/2.9/dataweave-formats-flatfile#examples) example that sets a `schemaPath`

- [XML](https://docs.mulesoft.com/dataweave/2.9/dataweave-cookbook-remove-certain-xml-attributes) example that uses `inlineCloseOn="empty"`
  to close any empty XML elements

## Use Reader and Writer Properties in DataWeave Functions

The DataWeave `read`, `readUrl`, and `write` functions accept one or more comma-separated property
configurations within curly braces.

In the header of the following script, the value of `myVar` is a `read` function that inputs an XML
sample with an empty child element (`<ex1></ex1>`). The function passes an XML reader property
`{nullValueOn: "empty"}` that converts the value of the empty element to `null`.

In the body of the script, a `write` function accepts the value of `myVar` as input. The function
passes the JSON writer properties `{skipNullOn:"objects", writeAttributes:true}` to skip the object
with the `null` value (`<ex1>null</ex1>`) and to write the attribute and value of
`<ex3 a='greeting'>hello</ex3>`.

DataWeave Script:

```dataweave
%dw 2.0
var myVar = read("<greeting><ex1></ex1><ex2>hello</ex2><ex3 a='greeting'>hello</ex3></greeting>", "application/xml", {nullValueOn: "empty"})
output application/json with binary
---
write(myVar.greeting, "application/json", {skipNullOn:"objects", writeAttributes:true})
```

Output JSON:

```json
{
  "ex2": "hello",
  "ex3": {
    "@a": "greeting",
    "__text": "hello"
  }
}
```

The following examples pass reader properties to `readUrl`:

- [XML example](https://docs.mulesoft.com/dataweave/2.9/dataweave-formats-xml#example1)

- [ndjson example](https://docs.mulesoft.com/dataweave/2.9/dataweave-formats-ndjson#example2)

## See Also

- [DataWeave Formats](https://docs.mulesoft.com/dataweave/2.9/dataweave-formats)

- [Core Components](https://docs.mulesoft.com/mule-runtime/latest/about-components)

- [DataWeave Cookbook](https://docs.mulesoft.com/dataweave/2.9/dataweave-cookbook)
