This page explains how to use the bag_keys function in APL.
bag_keys
function in APL to extract the keys of a dynamic (bag) object as an array of strings. This is useful when you want to inspect or manipulate the structure of a dynamic field—such as JSON-like nested objects—without needing to know its exact schema in advance.
Use bag_keys
when you’re working with semi-structured data and want to:
Splunk SPL users
spath
command or use keys(_raw)
to retrieve field names. In APL, bag_keys
serves a similar purpose by returning an array of keys from a dynamic object.ANSI SQL users
bag_keys
is the APL equivalent for dynamically introspecting JSON objects.Name | Type | Description |
---|---|---|
bag | dynamic | The dynamic object whose keys you want to extract. |
string[]
containing the names of the keys in the dynamic object. If the input is not a dynamic object, the function returns null
.
bag_keys
to audit dynamic metadata fields in HTTP logs where each record contains a nested object representing additional request attributes.Query_time | uri | metadata | key_list |
---|---|---|---|
2025-05-26 12:01:23 | /login | {os: Windows, browser: Firefox, device: Desktop} | [‘os’, ‘browser’, ‘device’] |