Monetize360

Convert JSON to CSV

Convert JSON array data to CSV format and save as a file

Convert JSON to CSV

Convert an array of JSON objects to CSV format and save it as a file. This function automatically extracts headers from the JSON data and handles missing fields across rows.

Technical Name: JsonToCsvFileConverter

Properties

  • Execution Mode: SYNC
  • Type: NATIVE
  • Category: System Functions
  • Function ID: 7f9a1ea8-5d9a-4f2b-a8f6-8f6b5d9a1ea4

Input Schema

Required Parameters

ParameterTypeDescription
dataarrayArray of JSON objects to convert to CSV. Each object represents a row, and object keys become column headers

Optional Parameters

ParameterTypeDescription
fileNamestringName of the CSV file to generate (default: "export.csv")
includeDateInFilenamestringWhether to include date in filename - "true" or "false" (default: "true")
includeHeaderstringWhether to include headers in CSV - "true" or "false" (default: "true")

[Image placeholder: JsonToCsv function configuration panel]

Input Example

Basic Conversion

{
  "data": [
    {
      "name": "John Doe",
      "email": "john@example.com",
      "age": 30
    },
    {
      "name": "Jane Smith",
      "email": "jane@example.com",
      "age": 25
    }
  ],
  "fileName": "users.csv"
}

Without Headers

{
  "data": [
    {"product": "Widget A", "price": 19.99, "quantity": 100},
    {"product": "Widget B", "price": 29.99, "quantity": 50}
  ],
  "fileName": "products.csv",
  "includeHeader": "false",
  "includeDateInFilename": "true"
}

With Date in Filename

{
  "data": [
    {
      "orderId": "ORD001",
      "customer": "Acme Corp",
      "amount": 1500.00,
      "status": "completed"
    },
    {
      "orderId": "ORD002",
      "customer": "Tech Inc",
      "amount": 2300.50,
      "status": "pending"
    }
  ],
  "fileName": "orders_export.csv",
  "includeDateInFilename": "true",
  "includeHeader": "true"
}

Output Schema

FieldTypeDescription
fileIdstring (uuid)ID of the generated CSV file in the file storage system
fileNamestringName of the generated CSV file (includes date suffix if enabled)
rowCountintegerNumber of rows in the exported file

Output Example

{
  "fileId": "a7b9c4d2-3e5f-4a1b-9c8d-7e6f5a4b3c2d",
  "fileName": "users_export_20240120_143022.csv",
  "rowCount": 2
}

[Image placeholder: CSV output visualization]

How It Works

  1. Extracts Headers: Automatically collects all unique keys from all JSON objects to create column headers
  2. Handles Missing Fields: If a row doesn't have a field present in other rows, it's filled with an empty string
  3. Converts Values: All values are converted to strings for CSV format
  4. Generates File: Creates CSV file and uploads it to file storage
  5. Date Suffix: Optionally appends timestamp to filename (format: yyyyMMdd_HHmmss)

Use Cases

Convert API Response to CSV

Convert JSON API response data to CSV:

{
  "data": [
    {"id": 1, "name": "Item 1", "value": 100},
    {"id": 2, "name": "Item 2", "value": 200}
  ],
  "fileName": "api_data.csv"
}

Export Workflow Results

Export workflow execution results to CSV:

Start → ProcessData → JsonToCsv → EmailNotification(attach CSV) → End

Transform Data Before Export

Transform and convert data:

Start → FetchMData → TransformData → JsonToCsv → End

[Image placeholder: Workflow examples]