Table to JSON

Converts the selected columns content to a JSON value row-wise or column-wise. It also has an option to "undo" - with some limitations - the JSON to Table transformation, and can create JSON values for each row based on the column names.
Example input table:

a.ba.cd
b0c0d0
b1c1d1
With the different parameters, the following JSON values are generated:
Row-oriented (datatable as one JSON value):
[ {
  "a.b" : "b0",
  "a.c" : "c0",
  "d" : "d0"
}, {
  "a.b" : "b1",
  "a.c" : "c1",
  "d" : "d1"
} ]
Keep rows (column names treated as paths, default separator: .):
{
  "a" : {
    "b" : "b0",
    "c" : "c0"
  },
  "d" : "d0"
}
{
  "a" : {
    "b" : "b1",
    "c" : "c1"
  },
  "d" : "d1"
}
Column-oriented (row keys as JSON value, with the key: "ROWID"):
{
  "ROWID" : [ "Row0", "Row1" ],
  "a.b" : [ "b0", "b1" ],
  "a.c" : [ "c0", "c1" ],
  "d" : [ "d0", "d1" ]
}

Options

Input columns
The selected columns will be transformed.
Row keys
Configure how row keys should be handled in the JSON output.
  • Omit row key: The row keys will be omitted, not used in the generated JSON value (which are arrays when the rows are not kept).
  • Row key as JSON value with key: The row keys will be included in the generated JSON (array) value with the specified key.
  • Row key as JSON key: The row keys are added to the generated JSON value as a key, in this case not an array, but an object is created.
Row key name
The key name to use when row keys are included as JSON values.
Column names as paths
When enabled, column names are treated as hierarchical paths using the specified separator.
Path separator
When column names as paths is enabled, this value will be used to find the keys for JSON columns based on the column names.
Aggregation direction
Configure how to aggregate the selected columns into JSON.
  • Row-oriented (n input rows → 1 output cell): The values from the selected columns are collected and concatenated row-wise to a JSON object/array, after that these are combined by the rows to a single JSON value.
  • Keep rows (n input rows → n output cells): The selected columns are combined to a new JSON column containing the values from the columns and the name of the columns as keys. This option does not combine the rows of the input table.
  • Column-oriented (n input rows → 1 output cell): The values from the selected columns are collected and concatenated column-wise to a JSON object/array, after that these are combined by the columns to a single JSON value.
Remove source columns
When checked, the source columns are removed when the rows are kept. It has no effect for the other aggregation direction options, when all columns are removed.
Missing values
Configure how missing values should be handled in the JSON output.
  • are omitted: Missing values from the input table do not generate a key in the resulting JSON structure, they are omitted completely. Note that in a column-oriented transformation missing cells will still be inserted as null values in the column's array because otherwise the row arrays for different columns may have different numbers of entries. This would make it impossible to reconstruct the original table.
  • are inserted as 'null': Missing values from the input table are inserted as null values.
Output column name
Name of the resulting JSON column.

Input Ports

Icon
A datatable

Output Ports

Icon
Table containing the JSON column

Views

This node has no views

Workflows

Links

Developers

You want to see the source code for this node? Click the following button and we’ll use our super-powers to find it for you.