CSV to JSON V2 transforms a CSV into a JSON object.

Take a look at the configuration parameters of the component:

  • Headers: list of CSV headers to be read - each CSV header is converted into a JSON property. It will be shown only if the CSV Has Reader option is disabled.

  • Delimiter: delimiter in which the CSV is configured.

  • CSV Has Reader: keep the option enabled if the CSV to be transformed has headers in the beginning of the array, string or file.

  • CSV as File: if the option is activated, the component will wait for a file to generate the output JSON; otherwise, it will be necessary to stop a CSV as array or string.

  • File Name: when the CSV as File option is enabled, this field will be shown and must receive the name of the CSV file.

  • Body: when the CSV as File option is disabled, this field will be shown and a CSV in JSON format (array or string) must be provided.

  • Fail On Error: if the option is enabled, the execution of the pipeline with error will be interrupted; otherwise, the pipeline execution proceeds, but the result will show a false value for the “success” property.

Messages Flow

Input

The component waits for a message with the property. You can provide the CSV data as an array of strings:

{
"data": ["HEADER1,HEADER2,HEADER3", "LINE1,LINE1,LINE1", ...]
}

as an unique string:

{
"data": "HEADER1,HEADER2,HEADER3\nLINE1,LINE1,LINE1\nLINE2,LINE2,LINE2"
}

or as a file:

File Name: arquivo.csv

Output

{
"data": [{"HEADER1": "LINE1",
"HEADER2": "LINE1",
"HEADER3": "LINE1"
},
{"HEADER1": "LINE2",
"HEADER2": "LINE2",
"HEADER3": "LINE2"
}, ....]
}

If you receive an unique string:

{       
"data": [{"HEADER1": "LINE1",
"HEADER2": "LINE1",
"HEADER3": "LINE1"
},
{"HEADER1": "LINE2",
"HEADER2": "LINE2",
"HEADER3": "LINE2"
}]
}

Did this answer your question?