-
Notifications
You must be signed in to change notification settings - Fork 460
CsvToJsonConversionRecipes
pozil edited this page Nov 14, 2024
·
3 revisions
Demonstrates how to use DataWeave in Apex to convert CSV to JSON.
Group DataWeaveInApex Recipes
Converts CSV to JSON.
Uses the dw/csvToJsonBasic.dwl
DataWeave script.
public static String convertCsvToJson(String csvPayload)
Name | Type | Description |
---|---|---|
csvPayload | String | CSV data to convert to JSON |
String
JSON string
Converts CSV to JSON while renaming object fields.
Uses the dw/csvToJsonWithFieldRenaming.dwl
DataWeave script.
public static String convertCsvToJsonWithFieldRenaming(String csvPayload)
Name | Type | Description |
---|---|---|
csvPayload | String | CSV data to convert to JSON |
String
JSON string
Converts CSV to JSON with a custom ;
CSV separator.
Uses the dw/csvSeparatorToJson.dwl
DataWeave script.
Notice that the script input MIME type specifies separator=';'
.
public static String convertCsvWithCustomSeparatorToJson(String csvPayload)
Name | Type | Description |
---|---|---|
csvPayload | String | CSV data to convert to JSON |
String
JSON string