Convert CSV to JSON
CSV - Convert to JSON
Section titled “CSV - Convert to JSON”The CSV to JSON conversion functionality allows extracting data from CSV files and converting it into an array of JSON objects.
Endpoint
Section titled “Endpoint”POST /api/v1/Csv/ConvertToJsonRequest Parameters
Section titled “Request Parameters”| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| Filename | string | Yes | - | Filename of the source CSV file, must include the .csv extension |
| FileContent | string | Yes | - | Base64-encoded content of the CSV file |
| Delimiter | string | No | ”,“ | Character used to separate values in the CSV file. For tab delimiter, use \t |
| HeaderInFirstRow | boolean | No | true | Determines if the first row contains column headers |
| Encoding | string | No | ”UTF8” | Encoding type used for text extraction. Options: “UTF8”, “Latin1”, “BigEndianUnicode”, “UTF16”, “ASCII” |
| Mapping | string | No | - | JSONata mapping to transform the CSV data. For more information: https://docs.uflow.dev/jsonata |
| Unescape | boolean | No | false | Controls if quoted values are unescaped |
| Trim | enum | No | ”All” | Controls if values are trimmed. Options: “All”, “None” |
Response
Section titled “Response”| Name | Type | Description |
|---|---|---|
| data | string | JSON data extracted from the CSV file |
| schema | string | JSON schema of the extracted data (either inferred or provided as input) |
Implementation Details
Section titled “Implementation Details”The conversion process works as follows:
- The file content is decoded from Base64 and converted to the specified encoding
- The CSV is parsed using a delimiter-separated values reader
- Each row is converted to a dictionary with column names as keys
- The collection of dictionaries is serialized to JSON
- If a JSONata mapping is provided, it’s applied to transform the data
- The result is returned as a string in the response
Usage Notes
Section titled “Usage Notes”- The filename must end with “.csv” extension
- The file content must be a valid Base64-encoded string
- If a mapping is provided, it will be applied to transform the output
- The output is formatted with indentation for readability
- The process supports different encodings for handling various text formats
Credit Cost
Cost: 1 credit(s) per 10000 rows
Note: Cost depends on the number of rows in the document
This functionality is particularly useful for data transformation workflows that need to convert CSV data into structured JSON for further processing or integration with JSON-based systems.