json-to-csv
Service icon

JSON To CSV

Stable version 1.0.0 (Compatible with OutSystems 11)
Uploaded
 on 1 Feb (23 hours ago)
 by 
0.0
 (0 ratings)
json-to-csv

JSON To CSV

Documentation
1.0.0

The component exposes a single server-side action that transforms JSON into CSV.

This is especially useful for:

  • Downloading data as CSV files

  • Exporting API responses or logs

  • Preparing data for Excel or other tools that import CSV

The output is returned as Text (CSV content). You can then convert it to BinaryData using TextToBinaryData to download it as a file.


TransformJSONToCSV

Purpose: Converts a JSON string into CSV text.

Inputs

  • JsonText (Text)
    The JSON input to transform. Must be a JSON array of objects:

  • Delimiter (Text) (optional)
    The delimiter used between CSV columns.

  • IncludeHeader (Boolean) (optional)
    If True, writes a header row containing column names.

Outputs

  • CSVText (Text)
    The generated CSV content as text.

  • IsJSONValid (Boolean)
    True only when:

    • the JSON parses successfully


Transformation Rules

1) Validation (Strict Mode)

The action supports only JSON in this shape:

Supported:

[   { "Id": 1, "Name": "Test 1" },   { "Id": 2, "Name": "Test 2" } ]

Not supported (returns IsJSONValid = False):

  • Non-JSON input (e.g., hello world)

  • A single object (not an array)

  • Arrays with scalars (e.g., [1,2,3])

  • Mixed arrays (e.g., [{...}, 1])


2) Header Generation

  • Headers are generated from the union of keys across all rows.

  • Nested object keys are flattened using dot notation.

  • Missing values for a column in a row will be exported as empty cells.


3) Flattening Nested Objects

Nested objects are flattened into Parent.Child:

Input:

{ "Address": { "City": "Cluj", "Zip": "400000" } }

CSV columns:

  • Address.City

  • Address.Zip


4) Arrays

Arrays are written into a single CSV cell.

  • Arrays of scalars:

    { "Tags": ["dev", "outsystems"] }

    becomes:

    Tags = dev;outsystems
  • Arrays containing objects:

    { "Projects": [ { "Code": "PRJ-1" }, { "Code": "PRJ-2" } ] }

    Each item is serialized compactly and joined into one cell.


Download as CSV (Recommended Pattern)

  1. Call TransformJSONToCSV

  2. If IsJSONValid = False  -> show validation error to user

  3. Convert to binary using TextToBinary and download.