Back to Home
$jsonClear
$jsonClear clears the entire current JSON object from
memory. After calling it, all JSON functions return empty until
$jsonParse or $jsonSet is called again.
Syntax
$jsonClear
No parameters.
What happens
$jsonParseloads a JSON object into memory.$jsonClearwipes the entire object.-
Any
$json,$jsonExists,$jsonStringify, or similar call after this returns empty.
Example 1: Clear and confirm
$nomention
$jsonParse[{"username":"Zubariel"}]
Before: $json[username]
$jsonClear
After: $json[username]
What happens:
$jsonParseloads the object.$json[username]returnsZubariel.$jsonClearwipes the object from memory.$json[username]now returns empty.
Output:
Before: Zubariel
After:
Example 2: Reset between two separate objects
$nomention
$jsonParse[{"name":"Zubariel"}]
Name: $json[name]
$jsonClear
$jsonParse[{"name":"Speshy"}]
Name: $json[name]
What happens:
- The first
$jsonParseloads the first object. $jsonClearremoves it so there is no overlap.- The second
$jsonParseloads a fresh object. $json[name]returns the new value.
Output:
Name: Zubariel
Name: Speshy
Common uses
- Working with multiple JSON objects in one command: clear before parsing the next one
- Resetting state: ensure no leftover data from a previous parse affects the current one
See also
- $jsonParse: to load a new object after clearing
- $jsonUnset: to remove a single key instead of the whole object