Newer Version Available

This content describes an older version of this product. View Latest

DataWeave in Apex (Developer Preview)

DataWeave in Apex uses Mulesoft’s DataWeave library to read and parse data from one format, transform it, and export it in a different format. You can create DataWeave scripts as metadata and invoke them directly from Apex. Like Apex, DataWeave scripts are run within Salesforce application servers, enforcing the same heap and CPU limits on the executing code.

Feature is available as a developer preview. Feature isn’t generally available unless or until Salesforce announces its general availability in documentation or in press releases or public statements. All commands, parameters, and other features are subject to change or deprecation at any time, with or without notice. Don't implement functionality developed with these commands or tools in a production environment. You can provide feedback and suggestions for the DataWeave in Apex feature in the Trailblazer Community.

Note

Enterprise applications often require transformation of data between formats such as CSV, JSON, XML, and Apex objects. DataWeave in Apex complements native Apex support for JSON and XML processing, and makes data transformation easier to code, more scalable, and efficient. Apex developers can focus more on solving business problems and less on addressing the specifics of file formats.

DataWeave is the MuleSoft expression language for accessing, parsing, and transforming data that travels through a Mule application. For detailed information, see DataWeave Overview

You don’t have to be a MuleSoft customer or have any specific Salesforce license to use DataWeave in Apex.

Note

The following are some use-cases for DataWeave in Apex.

  • Serializing Apex objects with custom date formats
  • Serializing and deserializing JSON with Apex reserved keywords
  • Performing custom transformations like removing or adding namespaces or removing __c suffixes
  • Parsing and transforming RFC 4180 compliant CSV (Comma-Separated Values) data