bmel:json-valid¶
Category: JSON · Returns: bmel:boolean
Signature
bmel:json-valid(value: bmel:any)
Description¶
Returns true if the input string is valid, parseable JSON; false otherwise. Useful as a guardrail condition in LLM_INFERENCE_FRAME and TOOL_EXECUTION_FRAME to detect when a model was expected to return structured JSON output but produced malformed text instead (hallucinated syntax, truncated output, refusal text). Can be combined with bmel:if to provide a fallback value when parsing would fail.
Arguments¶
| Parameter | Type | Required | Description |
|---|---|---|---|
value | bmel:any | The value to validate. Non-string inputs (objects, arrays, numbers, booleans) always return true. Null returns false. |
Examples¶
The model returned valid JSON
bmel:json-valid({invokeAgent:Response Payload}.$.output_text)
Invalid JSON output
bmel:not(bmel:json-valid({invokeAgent:Response Payload}.$.output_text))