Treat expressions

Figure 64. TreatExpr

TreatExpr

A treat expression checks that a JSONiq value matches a given sequence type. If it is not the case, an error is raised.

Example 146. Treat as expression

1 treat as integer
      

Result (run with Zorba): 1


Example 147. Treat as expression

1 treat as string
      

Result (run with Zorba): An error was raised: "xs:integer" cannot be treated as type xs:string


Example 148. Treat as expression

"foo" treat as string
      

Result (run with Zorba): foo


Example 149. Treat as expression

{ "foo" : "bar" } treat as object
      

Result (run with Zorba): { "foo" : "bar" }


Example 150. Treat as expression

({ "foo" : "bar" }, { "bar" : "foo" }) treat as json-item+
      

Result (run with Zorba): { "foo" : "bar" } { "bar" : "foo" }


Example 151. Treat as expression

[ 1, 2, 3 ] treat as array?
      

Result (run with Zorba): [ 1, 2, 3 ]


Example 152. Treat as expression

() treat as ()
      

Result (run with Zorba):