Newer Version Available
DataWeave in Apex (Beta)
DataWeave in Apex uses the Mulesoft 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.
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.
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