HTTP & JSON jsonSet

$jsonSet[]

Sets a key to a value in the current JSON object. The value is stored as-is (string, number, boolean, or nested JSON).

Syntax
$jsonSet[key;value]

Parameters

Parameter Type Required Default Description
key string check_circle Required The key name to set in the JSON object. Supports dot notation for nested keys (e.g., 'user.name' or 'data.items.0').
value any check_circle Required The value to assign to the key. Can be a string, number, boolean, or nested JSON string.

Return Value

void

Modifies the JSON object in-place. Creates the key if it does not exist, updates it if it does.

$jsonSet is the primary way to build and modify JSON objects. It stores values while preserving their type — numbers remain numeric, booleans remain boolean. Dot notation allows setting deeply nested values: $jsonSet[user.profile.avatar;url] creates the intermediate objects automatically. Use $jsonSetString to force a value to be stored as a string.

Examples

Set simple key-value pairs

$json[]
$jsonSet[name;Alice]
$jsonSet[age;25]
$jsonSet[active;true]
$jsonStringify[]

Set a nested value using dot notation

$jsonParse[{"user":{}}]
$jsonSet[user.name;Bob]
$jsonSet[user.address.city;Paris]
$jsonStringify[]

Type-preserving set

$json[]
$jsonSet[count;42]
$jsonSet[price;19.99]
$jsonSet[isAdmin;true]
$jsonPretty[]