HTTP & JSON jsonKey

$jsonKey[]

Returns the current key during a $jsonForEach iteration. Must be called inside a $jsonForEach block.

Syntax
$jsonKey[]

Return Value

string

The current iteration key as a string. Returns an empty string if called outside a $jsonForEach block.

$jsonKey returns the current key name during $jsonForEach iteration. It is only meaningful inside a $jsonForEach … $endJsonForEach block. Pair with $jsonValue[] (no arguments) to access the corresponding value. This is the primary way to process key-value pairs in JSON objects.

Examples

Display key-value pairs during iteration

$jsonParse[{"name":"Alice","age":25,"city":"Paris"}]
$jsonForEach[]
$jsonKey[]: $jsonValue[]
$endJsonForEach

Conditional logic based on key name

$jsonParse[{"name":"Alice","password":"secret","email":"[email protected]"}]
$jsonForEach[]
$if[$jsonKey[]!=password]
$jsonKey[]: $jsonValue[]
$endif
$endJsonForEach

Build a string from keys

$jsonParse[{"status":"ok","code":200}]
$jsonForEach[]
$jsonKey[]=$jsonValue[]
$endJsonForEach