|
|
xdmp:from-json(
|
|
$arg as xs:string
|
| ) as item()* |
|
 |
Summary:
Parses a string as JSON, returning an item sequence.
|
Parameters:
$arg
:
JSON input to be parsed.
|
|
Usage Notes:
JSON objects are parsed as maps.
The JSON null value is represented as the empty sequence.
Nested arrays in JSON are flattened out.
Any codepoints in the JSON string that aren't allowed in XML are
rejected and an error is thrown.
|
Example:
xdmp:from-json('["a", false]')
=> ("a", fn:false())
|
|
|
|
xdmp:to-json(
|
|
$item as item()*
|
| ) as xs:string |
|
 |
Summary:
Returns a string representing a JSON
serialization of a given item sequence.
|
Parameters:
$item
:
The item sequence whose JSON serialization is returned.
|
|
Usage Notes:
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.
|
Example:
xdmp:to-json(("a",fn:false()))
=> ["a", false]
|
|
|