Excerpt |
---|
Extracts the key values from an Object data type column and stores them in an array of String values. |
Column reference example:
D code |
---|
derive type:single value:KEYS('object1') as:'objKeys' |
Output: Generates a new objKeys
column containing an array of all of the keys found in the key-value Objects found in the object1
column.
Array literal reference example:
See the example below.
D code |
---|
derive type:single value:KEYS(obj_col) |
Argument | Required? | Data Type | Description |
---|
obj_col | Y | String or Object | Name of column or Object literal whose keys are to be extracted into an array |
obj_col
Object literal or name of the Object column whose keys you want to extract into an array.
Required? | Data Type | Example Value |
---|
Yes | Object literal or column reference | myObj |
Example - Basic keys example
Source:
Following dataset contains configuration blocks for individual features. These example blocks are of Object type.
Code formatting has been applied to the Object data to improve legibility.
FeatureName | Configuration |
---|
Whiz Widget | Code Block |
---|
{
"enabled": "true",
"maxRows": "1000",
"maxCols": "100"
} |
|
Magic Button | Code Block |
---|
{
"enabled": "false",
"startDirectory": "/home",
"maxDepth": "15"
} |
|
Happy Path Finder | Code Block |
---|
{
"enabled": "true"
} |
|
Transform:
The following transform extracts the key values from the Object data in the Configuration
column.
D code |
---|
derive type:single value: KEYS(Configuration) as: 'keys_Configuration' |
Results:
The keys_Configuration
column contains the arrays of the key values.
FeatureName | Configuration | keys_Configuration |
---|
Whiz Widget | Code Block |
---|
{
"enabled": "true",
"maxRows": "1000",
"maxCols": "100"
} |
| Code Block |
---|
["enabled","maxRows","maxCols"] |
|
Magic Button | Code Block |
---|
{
"enabled": "false",
"startDirectory": "/home",
"maxDepth": "15"
} |
| Code Block |
---|
["enabled","startDirectory","maxDepth"] |
|
Happy Path Finder | Code Block |
---|
{
"enabled": "true"
} |
| |
Example - Create an Object of product properties
Include Page |
---|
| EXAMPLE - ARRAYSTOMAP Function |
---|
| EXAMPLE - ARRAYSTOMAP Function |
---|
|