JSON to CSV Node
Overview
This node converts JSON (JavaScript Object Notation) data into CSV (Comma-Separated Values) format.
Inputs
- json (object): The JSON data to be converted. It should be an array of objects.
Output
- csv (string): The converted CSV data.
Properties
- Separator (text): The character used as the separator in the resulting CSV data. Default is a comma (,).
- Header (toggle): Indicates whether to include a header row in the CSV data. If enabled, the property names of the JSON objects will be used as the header row.
Usage
- Connect a node that provides JSON data to the “json” input of the JSON to CSV node.
- Optionally, adjust the “Separator” property to specify the desired separator character for the CSV data.
- Enable or disable the “Header” property depending on whether you want to include a header row in the CSV data.
- The converted CSV data will be available at the “csv” output of the node.
Error Handling
- If no JSON data is provided, an error message will be set at the “csv” output indicating that no data was provided.
- If the JSON data is invalid or not in the expected format (an array of objects), an error message will be set at the “csv” output indicating an invalid JSON data error.
Note
- The JSON data should be an array of objects, where each object represents a row in the CSV data.
- If the JSON objects have different properties, the resulting CSV data will have empty values for missing properties.