HTTP & JSON
jsonUnset
$jsonUnset[]
Removes a key and its associated value from the current JSON object.
Syntax
$jsonUnset[key]
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| key | string | check_circle Required | — | The key to remove from the JSON object. Supports dot notation for nested keys. If the key does not exist, nothing happens. |
Return Value
void
Modifies the JSON object in-place by deleting the specified key.
$jsonUnset removes a key-value pair from the JSON object. It works with dot notation for nested keys. If the specified key does not exist, no error is thrown — the operation is silently ignored. This is useful for cleaning API responses, removing sensitive fields (like passwords) before logging, or pruning empty configuration options.
Examples
Remove a simple key
$jsonParse[{"name":"Alice","age":25,"temp":"deleteMe"}]
$jsonUnset[temp]
$jsonStringify[]
// Output: {"name":"Alice","age":25}
Remove a nested key
$jsonParse[{"user":{"name":"Bob","password":"secret","email":"[email protected]"}}]
$jsonUnset[user.password]
$jsonPretty[]
Conditionally remove a key
$jsonParse[$httpResult]
$if[$jsonExists[error]==true]
$jsonUnset[error]
$endif