Task Purpose
CSV (Comma Separated Values) is widely used for tabular data and often associated with spreadsheet applications. JSON (JavaScript Object Notation) is a readable format used to store structured data.
The csvStringToJson task reference converts a CSV string to JSON format.
Given an input file like this:
first_name | last_name | postalcode | enrolled |
---|---|---|---|
Jane | Smith | 12345 | true |
John | Walker | false |
The CSV should look like this:
first_name;last_name;postalcode;enrolled
Jane;Smith;12345;true
John;Walker;;false
To parse correctly, the semicolon is the field delimiter. This means that when a semicolon is matched, a new JSON entry is created.
As a result, the conversion to JSON generates this:
{
"first_name": "Jane",
"last_name": "Smith",
"postalcode": "12345",
"enrolled": "true"
},
{
"first_name": "John",
"last_name": "Walker",
"postalcode": "",
"enrolled": "false"
}
Properties
Input and output parameters are shown below.
Incoming | Type | Description |
---|---|---|
input | String | Input CSV content to be converted to JSON. |
headersIncluded | Boolean | Headers included in input. |
headerRow | Array | Optional array of headers to use for mapping. |
Outgoing | Type | Description |
---|---|---|
response | String | Response output is CSV in JSON format. |
How to Configure
Upload a CSV file with the input variables for the workflow. The Reference variable for the input
is the contents of the CSV file and the variable source is static. Set the headersIncluded
variable to True
.
You can convert a CSV file into Base64 format using a converter tool of your preferred choice.
The response
that returns for this task are the comma separated values converted into a JSON format. You can view the response of the outgoing properties in Operations Manager when the task is complete.
Potential Use Case
Let’s say you are building a workflow and you need to convert the inputs into JSON format. Rather than fill in a JSON form to provide the workflow with the input job variables, you can upload a CSV file with the input variables for the workflow. After the comma separated values are converted to JSON with the csvStringToJson
task, the variables can be queried from the output and used in further tasks.
References
See the API references to: