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_csv is the CSV data which would be converted to JSON.
  • options contains the customization options:
    • nested_keys is 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 is true.
    • nested_key_separator is the character which has been used in the provided key headers. Default value is ..
    • skip_empty_lines is a boolean value which determines whether to skip empty lines from the provided CSV. Default value is false
    • skip_records_with_empty_values is a boolean value which determines whether to skip empty values from the provided CSV. Default value is false.
    • delimiter determines the character used in the provided CSV to separate the fields in a row.
    • record_delimiter determines the character used in the provided CSV to separate the rows.
    • quote determines 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."
}

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."
  }
}

Notes

More options will be added in the future.