JSON to CSV V2

Know the component and how to use it.

Micaella Mazoni avatar
Written by Micaella Mazoni
Updated over a week ago

IMPORTANT: This documentation has been discontinued. Read the updated JSON to CSV V2 documentation on our new documentation portal.

JSON to CSV V2 allows the creation of files and CSV structures from an input JSON.

Take a look at the configuration parameters of the component:

  • Output as File: if the property is activated, the generated CSV will be saved as file; otherwise, the result will be an array of strings and each one of its indexes corresponds to a line of the CSV.

  • Headers: headers of the CSV, separated by comma. Eg: header1,header2,...,headerN. The headers must have the same name of the JSON object keys.

  • Delimiter: delimiter to be used to generate the CSV.

  • Body: input JSON from which the CSV will be generated. The JSON must be an array of objects.

  • Show Headers: if the property is activated, the headers will be informed in the CSV; otherwise, the CSV won't show the headers.

  • Generate Columns With Quotes: if the property is activated, all the column values of all the lines will be generated with double quotes, unless it's necessary to escape some special character (double quotes and the delimiter inside the column value).

  • Coalesce: if the property is activated, any type of JSON object will be created as string with the CSV value; otherwise, an exception will be thrown if the value is an object or an array.

  • Append: if the property is activated, the data will be added to an existing file (nonexistent files will be created); otherwise, a new file will be created at each execution. This option will be displayed only when Output as File is activated.

  • End Of Line Policy: line break inside the file policy (LINUX = \n and WIDOWS = \r\n). This option will be displayed only when Output as File is activated.

  • File Name: name of the CSV file to be generated. This option will be displayed only when Output as File is activated.

  • 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

It's necessary to inform an array of objects in the Body field and inform in the Header field the headers that correspond to the keys of these objects. Example:

Headers: header1,header2,header3

Body:

[

{
"header1": "some_value",
"header2": "some_value",
"header3": "some_value"
}

]

Output

If the Output as File option is enabled:

{
"success": true,
"fileName": FILE_NAME
}

  • success: property that indicated if the execution has been successful or not

  • fileName: name of the generated file

If the Output as File option is disabled:

{
"success": true,
"data": [
"header1,header2,header3",
"some_value,some_value,some_value"
]
}

  • success: property that indicated if the execution has been successful or not

  • data: CSV generated as an array of strings

To better understand the flow of messages in the Platform, click here and read our article.

Did this answer your question?