Skip to content

bmel:json-pick

Category: JSON · Returns: bmel:string

Signature
bmel:json-pick(object: bmel:any, keys: bmel:array)

Description

Returns a new JSON string containing only the specified top-level keys from the input object. Keys not present in the input are silently ignored. Useful for extracting a known subset of a large or variable-shape payload (e.g. keeping only model, usage, and id from an OpenAI response) before persisting it to a STRING component. Supports dot-notation keys for nested picks (e.g. 'usage.prompt_tokens' extracts that leaf into a flat output key).

Arguments

Parameter Type Required Description
object bmel:any The source JSON object or string to pick from.
keys bmel:array Array of key names (strings) to include in the output. Supports dot-notation for nested paths.

Examples

Keep only the fields listed in the policy
bmel:json-pick({invokeAgent:Response Payload}.$.output, {invokeAgent:Request Payload}.$.policy.audit_fields)
Keep the fields the caller asked for
bmel:json-pick({invokeAgent:Response Payload}.$.output, {invokeAgent:Request Payload}.$.options.fields)

← Back to BMEL Reference