Product SiteDocumentation Site

3.5. ItemTypes for JSONiq Items

In XQuery, an ItemType is used to match certain items, for example in function signatures, return types, and a variety of other expressions. JSONiq extends XQuery's ItemType as follows:
      ItemType ::= -- everything so far --
        | JSONTest
        | StructuredItemTest

      JSONTest ::= 
          JSONItemTest
        | JSONObjectTest
        | JSONArrayTest

      StructuredItemTest ::= "structured-item" "(" ")"
      JSONItemTest ::= "json-item" "(" ")"
      JSONObjectTest ::= "object" "(" ")"
      JSONArrayTest ::= "array" "(" ")"
The semantics of these expressions are straightforward.
Example 3.1. JSON Items in Function Signatures and instance-of expressions
The following function returns any Objects that are members of an Array (see below for more on array navigation).
          declare function local:objects-in-array($a as array()) as object()* {
            for $i in 1 to jn:size($a)
            let $item := $a($i)
            where $iteminstance of object()
            return $item
          };