Product SiteDocumentation Site

Chapter 6. Builtin functions and operators

6.1. fn:boolean (aka Effective Boolean Value)
6.2. fn:collection
6.3. fn:data (aka Atomization)
6.4. fn:string (aka string value)
6.5. fn:trace
6.6. jn:decode-from-roundtrip
6.7. jn:encode-for-roundtrip
6.8. jn:json-doc
6.9. jn:keys
6.10. jn:members
6.11. jn:null
6.12. jn:parse-json
6.13. jn:size
6.14. Changes to cast semantics
6.15. Changes to arithmetic operation semantics
6.16. Changes to value comparison semantics
6.17. Changes to general comparison semantics
JSONiq defines a couple of basic builtin functions. Two of them define the atomized value and the effective boolean value of JSON items, and the others are for JSON navigation.

6.1. fn:boolean (aka Effective Boolean Value)

In XQuery, sequences can be converted to a boolean value. The effective boolean value is defined by invoking fn:boolean.
fn:boolean($arg as item()*) as xs:boolean
The definition of fn:boolean($arg) is changed as follows:
  • If $arg is a sequence whose first item is an object or an array, fn:boolean returns true.
  • If $arg is a singleton value of type js:null, fn:boolean returns false.
Example 6.1. Effective Boolean Value of JSONiq items
          Examples
          EBV( jn:null() )         	    false
          EBV( { } )                    true
          EBV ( { "foo": false } )   	  true
          EBV ( { "foo": 3, "bar":4 } )	true
          EBV( { "foo": 3 } )	          true
          EBV ( [1] )	                  true
          EBV ( ( [1], jn:null() ) )    true