Product SiteDocumentation Site

7.2.3. Renaming expressions

            JSONRenameExpr ::= "rename" "json" PrimaryExpr  ( "(" ExprSingle ")" )+ "as" ExprSingle
(for explanatory purposes, suboperands are replaced with a variable containing the result of their evaluation)
rename json $o($s) as $n
PrimaryExpr followed by all "(" ExprSingle ")" except the last one, is evaluated according to the semantics of dynamic function calls. It must return a single object $o. Otherwise, jerr:JNUP0008 is raised. After this evaluation, the last "(" ExprSingle ")" is interpreted as follows:
$s is atomized and cast to xs:string (jerr:JNUP0007 is raised upon failure).
Creates the update primitive jupd:rename-in-object($o, $s, $n). An error JNUP:0016 is raised if $o does not contain a pair with the key $s.
Example 7.3. Renaming an object pair
              rename json $o("foo") as "bar"