Contact Us 1-800-596-4880

Text Java Properties Format

MIME type: text/x-java-properties

ID: properties

The Text Java Properties format parses any Java properties file. This format represents simple key-value pairs. DataWeave represents these pairs as an object with string values.

Example: Represent a properties File in the DataWeave Format (dw)

This example shows how DataWeave represents a properties file.

Input

The following text/x-java-properties data is from a properties file. The file contains key-value pairs that provide host and port values. This content serves as the input payload to the DataWeave script.

host=localhost
port=1234

Source

The DataWeave script transforms the text/x-java-properties input payload to the DataWeave (dw) format and MIME type. It returns a string.

%dw 2.0
output application/dw
---
payload

Output

The output is an object in the DataWeave (dw) format. The object contains a collection of key-value pairs that match the text/x-java-properties input. Notice that the output wraps the values in quotation marks.

{
    host: "localhost",
    port: "1234"
}

Configuration Properties

DataWeave supports the following configuration properties for this format.

Reader Properties

There are no reader properties for this format.

Writer Properties

This format accepts properties that provide instructions for writing output data.

Parameter Type Default Description

bufferSize

Number

8192

Size of the buffer writer, in bytes. The value must be greater than 8.

deferred

Boolean

false

Generates the output as a data stream when set to true, and defers the script’s execution until the generated content is consumed.

Valid values are true or false.

encoding

String

null

The encoding to use for the output, such as UTF-8.

Supported MIME Types

This format supports the following MIME types.

MIME Type

*/x-java-properties

*/properties