Skip to main content
Use the todynamic function to parse a string as a dynamic value, such as a JSON object or array. This function is especially useful when your dataset contains structured data in string format and you want to access nested elements, iterate over arrays, or use dynamic-aware functions. You often find todynamic helpful when working with logs, telemetry, or security events that encode rich metadata or nested attributes in stringified JSON. By converting these strings into dynamic values, you can query, filter, and transform the nested fields using APL’s built-in support for dynamic types.

For users of other query languages

If you come from other query languages, this section explains how to adjust your existing queries to achieve the same results in APL.
Splunk automatically interprets structured JSON data and allows you to use dot notation directly on fields, without explicit conversion. In APL, you need to explicitly cast a JSON string into a dynamic value using todynamic.
In standard SQL, you typically use JSON_VALUE, JSON_QUERY, or CAST(... AS JSON) to access structured content in string format. In APL, use todynamic to convert a string to a dynamic value that supports dot notation and further manipulation.

Usage

Syntax

Parameters

Returns

A dynamic value. If the input isn’t a valid JSON string, the function returns null.

Example

You want to find events that match certain criteria such as URI and status code. The criteria are stored in a stringified dictionary. Query
Run in Playground Output
  • pack_array: Use this to combine scalar values into an array. Use pack_array when you don’t need named keys and want positional data instead.
  • bag_keys: Returns the list of keys in a dynamic dictionary. Use this to inspect or filter contents created by pack_dictionary.
  • bag_pack: Expands a dictionary into multiple columns. Use it to revert the packing performed by pack_dictionary.