Skip to content

bmel:json-keys

Category: JSON · Returns: bmel:array

Signature
bmel:json-keys(object: bmel:any)

Description

Returns an array of the top-level key names of a JSON object. Useful for detecting which fields an LLM returned in a structured output (e.g. checking whether a tool-call response includes the expected keys), for measuring output completeness, and for driving dynamic field iteration with bmel:count-if or bmel:contains-any. Returns an empty array for non-object inputs (arrays, scalars, null).

Arguments

Parameter Type Required Description
object bmel:any The JSON object or string whose top-level keys to return. If a string is provided it is parsed first.

Examples

Keys of the structured output
bmel:json-keys({invokeAgent:Response Payload}.$.output)
How many keys the output has
bmel:count(bmel:json-keys({invokeAgent:Response Payload}.$.output))

← Back to BMEL Reference