CSV to JSON
The /csv_to_json endpoint converts the given CSV data to JSON data.
Method: POST
To make a request, send the required parameters with the authorization header, via POST method, to the /csv_to_json endpoint.
Parameters
This endpoint accepts only two parameters, namely, source_csv and options:
source_csvis the CSV data which would be converted to JSON.optionscontains the customization options:nested_keysis a boolean value which tells whether the provided CSV contains nested data. If set, the nested data will also be converted to JSON. Default value istrue.nested_key_separatoris the character which has been used in the provided key headers. Default value is..skip_empty_linesis a boolean value which determines whether to skip empty lines from the provided CSV. Default value isfalseskip_records_with_empty_valuesis a boolean value which determines whether to skip empty values from the provided CSV. Default value isfalse.delimiterdetermines the character used in the provided CSV to separate the fields in a row.record_delimiterdetermines the character used in the provided CSV to separate the rows.quotedetermines the character which woukd be used to surround the value of a field.
Responses
A successful response looks like as follows:
{
"status": "success",
"data": {
"source_csv": "\"id\",\"name\",\"contact.email\"\n1,\"John Doe\",\"john.doe@example.com\"\n2,\"Jane Doe\",\"jane.doe@example.com\"",
"json": "[{\"id\":\"1\",\"name\":\"John Doe\",\"contact\":{\"email\":\"john.doe@example.com\"}},{\"id\":\"2\",\"name\":\"Jane Doe\",\"contact\":{\"email\":\"jane.doe@example.com\"}}]",
"options_applied": {
"nested_keys": true,
"nested_key_separator": "."
}
},
"message": "CSV has been successfully converted to JSON."
}
JSON
And if error occurs, the response is as follows:
{
"status": "error",
"error": {
"code": "INVALID_INPUT",
"message": "Invalid input provided.",
"details": "The 'source_csv' field must contain valid CSV."
}
}
JSON
Notes
More options will be added in the future.