Map operator

JSONiq follows the W3C standard for the map operator, except that it changes the syntax for the context item to $$ instead of the . syntax.

The following explanations, provided as an informal summary for convenience, are non-normative.

Figure 60. SimpleMapExpr

SimpleMapExpr

Figure 61. ContextItemExpr

ContextItemExpr

JSONiq provides a shortcut for a for-return construct, automatically binding each item in the left-hand-side sequence to the context item.

Example 135. A simple map

(1 to 10) ! ($$ * 2)
      

Result (run with Zorba): 2 4 6 8 10 12 14 16 18 20


Example 136. An equivalent query

for $i in 1 to 10
return $i * 2
      

Result (run with Zorba): 2 4 6 8 10 12 14 16 18 20