xdmp:to-json( $item as item()* ) as document-node()
Constructs a JSON document.
Parameters | |
---|---|
item | A sequence of items from which the JSON document is to be constructed. The item sequence from which the JSON document is constructed. |
An object-node()
is constructed from a
json:object
, a map:map
, or an
object-node()
.
An array-node()
is constructed from a
json:array
, a sequence of multiple items, or an
array-node()
.
A null-node()
is constructed from an empty sequence or
an null-node()
.
A boolean-node()
is constructed from an
xs:boolean
or a boolean-node()
.
A number-node()
is constructed from an
xs:integer
, a xs:decimal
, a
xs:float
, a xs:double
, or a
number-node()
. Integers with absolute value greater than
9007199254740991 are excluded and instead construct text()
nodes to avoid any loss of precision.
A text()
node is constructed from all other items.
To serialize a JSON node to a string, use xdmp:quote
.
xdmp:to-json(("a",fn:false())) => ["a", false]
let $object := json:object() let $_ := map:put($object,"a",111) return xdmp:to-json($object) => {"a":111}