HTTP & JSON
jsonExists
$jsonExists[]
Checks whether a specified key exists in the current JSON object.
Syntax
$jsonExists[key]
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| key | string | check_circle Required | — | The key to check for existence. Supports dot notation for nested keys. |
Return Value
boolean
Returns 'true' if the key exists in the JSON object, 'false' otherwise.
$jsonExists is essential for safely navigating JSON data, especially when working with external API responses that may have optional fields. It returns ‘true’ or ‘false’ as a string, making it directly usable in $if conditions. Always check for key existence before accessing values with $jsonValue to avoid ambiguity between missing keys and genuinely empty values.
Examples
Check if a key exists before reading
$jsonParse[$httpResult]
$if[$jsonExists[error]==true]
Error: $jsonValue[error]
$else
Success: $jsonValue[data]
$endif
Check nested key existence
$jsonParse[$httpResult]
$if[$jsonExists[user.email]==true]
Email: $jsonValue[user.email]
$else
No email provided.
$endif
Validate API response structure
$jsonParse[$httpResult]
$if[$jsonExists[data.items]==true]
Found $jsonArrayCount[data.items] items.
$else
Unexpected response format!
$endif