HTTP & JSON jsonClear

$jsonClear[]

Clears the current internal JSON object, resetting it to an empty state. All previously set keys, values, and arrays are discarded.

Syntax
$jsonClear[]

Return Value

void

Resets the internal JSON context to empty. Subsequent JSON functions operate on a fresh empty object.

$jsonClear resets the internal JSON state entirely. This is useful when you need to reuse JSON variables in a loop, or when switching between different JSON data sources to avoid data leakage. After clearing, the context is equivalent to calling $json[] with no arguments — an empty object ready for new data.

Examples

Clear JSON between operations

$jsonParse[{"temp":"data"}]
$jsonClear[]
$jsonSet[fresh;true]
$jsonStringify[]
// Output: {"fresh":true}

Reuse JSON context in a loop

$var[users;Alice;Bob;Charlie]
$var[i;0]
$repeat[3]
$jsonClear[]
$jsonSet[name;$arrayGet[users;$var[i]]]
Processing: $jsonStringify[]
$var[i;$math[$var[i]+1]]
$endRepeat

Reset after processing

$jsonParse[$httpResult]
$var[data;$jsonStringify[]]
$jsonClear[]
// JSON context is now clean for next operation