FLATTEN

Description

FLATTEN extracts either one or more keys from a dictionary. When extracting only one key the result is a list, when extracting multiple the result is a list of dictionaries

Example 1

FLATTEN(
  [
    {"key": "a", "name": "Thorben"},
    {"key": "b", "name": "Peter"},
    {"key": "c", "name": "Karin"},
    {"key": "d", "name": "Karl"},
  ],
  'key',
)

This returns a list of just the keys, so in this case ['a', 'b', 'c', 'd']

Example 2

FLATTEN(
  [
    {"key": "a", "name": "Karl", "age": 36},
    {"key": "b", "name": "Peter", "age": 26},
    {"key": "c", "name": "Karin", "age": 31},
  ],
  ["key", "name"]
)

This returns a list of dictionaries with just the mentioned the keys, so in this case

[
    {"key": "a", "name": "Karl"},
    {"key": "b", "name": "Peter"},
    {"key": "c", "name": "Karin"},
]

Last updated