The CSV (Comma-Separated Values) format is widely used to store and exchange tabular data in a simple way, compatible with spreadsheets and legacy systems. In the context of integrations, CSV allows you to transform files into JSON structures and vice versa, making it easier to manipulate and exchange information between different applications.
ADVANCED TIPSDelimiter:
The default is a comma, but you can use semicolon, tab, or another character depending on your data source.useMaps:
Enable this so each row is converted into an object (map), making it easier to access fields by header name.Limitations:
Be aware of fields containing line breaks, quotes, or delimiters within values. Make sure your CSV is well formatted to avoid parsing errors.Useful links:
CSV Apache CamelCommon error:
Missing or inconsistent headers can cause failures when converting to JSON. Always validate your input file.
The example below shows how a flow can receive a CSV file, process it, and return the data converted to JSON.
The flow is triggered by receiving a POST request with CSV data in the body.
Input:
The Unmarshal EIP converts the data from CSV format to Camel's internal structure.
delimiter: ",")useMaps: true).The Marshal EIP converts the internal structure to JSON (external format), which is returned as the API response.
Output (JSON):
We use cookies to enhance your experience on our site. By continuing to browse, you agree to our use of cookies.Learn more