Scoped Arguments
Values injected by an enclosing construct, read through the $arg expression.
Scoped arguments are $-prefixed identifiers that name a value injected by
an enclosing construct. They are read through the $arg expression:
{ "$arg": "$item" }{ "$arg": "$0" }Required
$arg(string): The scoped argument name (e.g."$item","$index","$content","$0","$1").
Returns: The value of the referenced argument.
Available Arguments
Each construct injects its own arguments, valid only within its scope:
| Argument | Injected by | Value |
|---|---|---|
$item | Maps | The current array item |
$index | Maps | The current item's index (0-based) |
$content | Translation tags | The tag's formatted chunks |
$0, $1 | Actions | The callback's positional args |
A document MUST NOT reference a scoped argument outside the scope of the construct that injects it. Schema validation cannot check dynamic scope, so an out-of-scope reference surfaces at resolution time: it is an error, and engines MUST report it.
Scopes nest lexically: a construct's injected arguments stay visible
throughout its scope, including inside nested constructs, and an inner
construct injecting an argument of the same name shadows the outer one
within its own scope. An action inside a map template reads both $item
and, when its callback fires, $0.
Accessing Nested Values
Append a JSON Pointer path to the identifier: the identifier runs to the
first /, and the rest is an
RFC 6901 pointer into the value:
{ "$arg": "$0/email" }{ "$arg": "$0/1" }{ "$arg": "$item/name" }Here $0/email reads the email property of the first positional
argument, $0/1 reads the second element of an array argument, and
$item/name reads the name property of the current map item. A pointer
that names no value resolves to undefined, as with data references.