Product SiteDocumentation Site

7.2. Update syntax: new updating expressions

The following syntax is introduced for updates.

7.2.1. Deleting expressions

            JSONDeleteExpr ::= "delete" "json" PrimaryExpr ( "(" ExprSingle ")" )+ 
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 or a single array $a. Otherwise, jerr:JNUP0008 is raised. After this evaluation, two cases can appear for interpreting the last "(" ExprSingle ")":
(for explanatory purposes, suboperands are replaced with a variable containing the result of their evaluation)
  • delete json $o($s)
    $s is atomized and cast to xs:string (jerr:JNUP0007 is raised upon failure).
    Creates the update primitive jupd:delete-from-object($o, $s). An error JNUP:0016 is raised if $o does not contain a pair with the key $s.
  • delete json $a($i)
    $i is atomized and cast to xs:integer (jerr:JNUP0007 is raised upon failure).
    Creates the update primitive jupd:delete-from-array($a, $i). An error JNUP:0016 is raised if $i is out of the range of the array $a.
Example 7.1. Deleting from an object and from an array
             delete json $o("foo")
             delete json $a(2)

Note:
If $o($s) or $a($i) resolves to an empty sequence, the produced update primitive will have no effect.