Skip to content

CSV to JSON Node

Overview

The CSV to JSON node allows converting data in CSV format (Comma-Separated Values) to JSON format (JavaScript Object Notation). It’s useful when needing to work with CSV data in an environment that requires JSON.


Inputs

csv: Accepts a string representing the CSV data to convert.


Outputs

json: Outputs the converted data in JSON format. It can be an array of objects if the CSV data includes a header row, or an array of arrays if there is no header.


Properties

Separator: Allows specifying the character used as a separator in the CSV data. The default is a comma (,).

Header: Indicates whether the CSV data includes a header row. If enabled, the first row of the CSV data will be used as property names in the resulting JSON objects.


Functioning

1. The node receives the CSV data through the “csv” input.

2. If no CSV data is provided, an error message is set in the “json” output.

3. The node attempts to convert the CSV data to JSON using the specified separator and header option.

4. If the conversion is successful, the JSON result is emitted through the “json” output.

5. If any error occurs during conversion, an error message is displayed on the console, and an error message is set in the “json” output.


Usage

1. Connect a node that provides CSV data to the “csv” input of the CSV to JSON node.

2. Optionally, adjust the “Separator” property to match the separator used in your CSV data.

3. Enable or disable the “Header” property depending on whether your CSV data includes a header row.

4. The converted JSON data will be available in the “json” output of the node.


Error Handling

  • If no CSV data is provided, an error message will be set in the “json” output indicating that no data was provided.
  • If the CSV data is invalid or cannot be properly parsed, an error message will be set in the “json” output indicating an error with invalid CSV data.