bag_keys()

Learn how to use the bag_keys() function to enumerate the root keys in a dynamic property bag object.

Enumerates all the root keys in a dynamic property bag object.

Syntax

bag_keys(object)

Parameters

NameTypeRequiredDescription
objectdynamic✔️The property bag object for which to enumerate keys.

Returns

An array of keys, order is undetermined.

Example

datatable(index:long, d:dynamic) [
    1, dynamic({'a':'b', 'c':123}), 
    2, dynamic({'a':'b', 'c':{'d':123}}),
    3, dynamic({'a':'b', 'c':[{'d':123}]}),
    4, dynamic(null),
    5, dynamic({}),
    6, dynamic('a'),
    7, dynamic([])
]
| extend keys = bag_keys(d)

Output

indexdkeys
1{
“a”: “b”,
“c”: 123
}
[
“a”,
“c”
]
2{
“a”: “b”,
“c”: {
“d”: 123
}
}
[
“a”,
“c”
]
3{
“a”: “b”,
“c”: [
{
“d”: 123
}
]
}
[
“a”,
“c”
]
4
5{}[]
6a
7[]