xdmp:to-json-string( $item as item()* ) as xs:string
Returns a string representing a JSON serialization of a given item sequence.
Parameters | |
---|---|
item | The item sequence whose JSON serialization is returned. |
XML nodes are serialized to JSON strings.
JSON has no serialization for infinity, not a number, and negative 0, therefore if you try and serialize INF, -INF, NaN, or -0 as JSON, an exception is thrown. If you want to represent these values in some way in your serialized JSON, then you can catch the exception (with a try/catch, for example) and provide your own value for it.
XQuery maps (map:map
types) serialize to JSON name-value
pairs.
xdmp:to-json-string(("a",fn:false())) => ["a", false]
xdmp:to-json-string( xdmp:from-json-string('{ "a":111 }')) => {"a":111}