Skip to main content

EXAMPLE - Extract Keys From Objects

You can extract the keys from an Object column into an Array of String values.

Functions:

Item

Description

KEYS Function

Extracts the key values from an Object data type column and stores them in an array of String values.

Source:

The following dataset contains configuration blocks for individual features, each of which has a different configuration. These example blocks are of Object type.

ヒント

In the following example configuration, the keys are the values on the left (e.g. enabled, maxRows, and maxCols), while the values for those keys are on the right side.

Code formatting has been applied to the Object data to improve legibility.

FeatureName

Configuration

Whiz Widget

{
 "enabled": "true",
 "maxRows": "1000",
 "maxCols": "100"
}

Magic Button

{
 "enabled": "false",
 "startDirectory": "/home",
 "maxDepth": "15"
}

Happy Path Finder

{
 "enabled": "true"
}

Transformation:

The following transformation extracts the keys from the Object data in the Configuration column.

Transformation Name

New formula

Parameter: Formula type

Single row formula

Parameter: Formula

keys(Configuration)

Parameter: New column name

'keys_Configuration'

Results:

The keys_Configuration column contains the arrays of the key values.

FeatureName

Configuration

keys_Configuration

Whiz Widget

{
 "enabled": "true",
 "maxRows": "1000",
 "maxCols": "100"
}
["enabled","maxRows","maxCols"]

Magic Button

{
 "enabled": "false",
 "startDirectory": "/home",
 "maxDepth": "15"
}
["enabled","startDirectory","maxDepth"]

Happy Path Finder

{
 "enabled": "true"
}
["enabled"]