Product SiteDocumentation Site

5.7.2. Treat expressions

TreatExpr
Figure 5.48. 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 5.134. Treat as expression
1 treat as integer
Result (run with Zorba):
1

Example 5.135. 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 5.136. Treat as expression
"foo" treat as string
Result (run with Zorba):
foo

Example 5.137. Treat as expression
{ "foo" : "bar" } treat as object
Result (run with Zorba):
{ "foo" : "bar" }

Example 5.138. Treat as expression
({ "foo" : "bar" }, { "bar" : "foo" }) treat as json-item+
Result (run with Zorba):
{ "foo" : "bar" } { "bar" : "foo" }

Example 5.139. Treat as expression
[ 1, 2, 3 ] treat as array?
Result (run with Zorba):
[ 1, 2, 3 ]

Example 5.140. Treat as expression
() treat as ()
Result (run with Zorba):