DataFormat Types (dw::extension::DataFormat)

The DataFormat module provides resources for registering a new data format for the DataWeave language. For an example, see Custom Data Formats Example.

Type Definition Description

DataFormat

type DataFormat = { binaryFormat?: Boolean, defaultCharset?: String, fileExtensions?: Array<String>, acceptedMimeTypes: Array<MimeType>, reader: (content: Binary, charset: String, settings: ReaderSettings) -> Any, writer: (value: Any, settings: WriterSettings) -> Binary }

Represents the DataFormat definition.

  • binaryFormat?: Boolean: True if this is data format is represented as binary instead of text. False if not present.

  • defaultCharset?: String: Default character set of this format, if any.

  • fileExtensions?: Array<String>: Returns the list of file extensions with the . (for example, .json, `.xml) to assign to this data format.

  • acceptedMimeTypes: Array<MimeType> The list of MIME types to accept.

  • reader: (content: Binary, charset: String, settings: ReaderSettings) → Any: Function that reads raw content and transforms it into the canonical DataWeave model.

  • writer: (value:Any, settings:WriterSettings) → Binary: Function that writes the canonical DataWeave model into binary content.

EmptySettings

type EmptySettings = Object

Represents a configuration with no settings.

EncodingSettings

type EncodingSettings = { encoding?: String }

Represents encoding settings:

  • encoding?: String: Encoding that the writer uses for output. Defaults to "UTF-8".

MimeType

type MimeType = String

Represents a MIME type, such as application/json.

Introduced in DataWeave version 2.2.0.

Settings

type Settings = Object

Reader or writer configuration settings.

Introduced in DataWeave version 2.2.0.

Was this article helpful?

💙 Thanks for your feedback!

Edit on GitHub