HTTP & JSON
jsonUnset
$jsonUnset[]
$jsonUnset removes a key, or an array element, from the JSON document. It returns an empty string.
Syntax
bdfd
$jsonUnset[(key);(...)]
Parameters
The path is given as separate arguments, one per level (no dot notation: a.b is a single key named a.b). Surrounding spaces are removed and empty arguments are skipped. A whole-number argument selects an element when the current value is an array; otherwise it is used as an object key. At most 100 arguments are accepted in total. With no argument, the whole document is emptied (same as $jsonClear: $jsonStringify then returns an empty string, not {}).
Behavior
- Removing an array element shifts the following elements down.
- If the path does not exist, the call does nothing and raises no error.
- Dot notation is not supported:
$jsonUnset[user.id]looks for a key literally nameduser.id. - Useful to remove sensitive fields (such as a token) before logging or displaying the document.
Examples
Delete Key from JSON Object
$jsonParse[{"token":"secret123","publicName":"Bot"}]
$jsonUnset[token]
$title[Sanitized JSON Object]
$description[Output after unset: `$jsonStringify`]
$color[#5865F2]
Try it
Paste an example into the playground to preview its message (functions that act on Discord are not run), or build the same thing with blocks.