xdmp.fromJSON( arg as Node ) as Sequence
Atomizes a JSON node, returning a JSON value.
Parameters | |
---|---|
arg |
A node of kind object-node() , array-node() ,
text() , number-node() , boolean-node() ,
null-node() , or document-node() .
|
An object-node()
atomizes as a json:object
.
An array-node()
atomizes as a json:array
.
A null-node()
atomizes as an empty sequence.
A boolean-node()
atomizes as an xs:boolean
.
A number-node()
atomizes as an xs:integer
,
xs:decimal
, or xs:double
value.
A text()
node atomizes as an xs:untypedAtomic
.
A document-node()
atomizes the same as its root.
This function returns the same result as fn:data
,
but it only works on JSON nodes.
To make a JSON node from a string, use xdmp:unquote
with the "format-json"
option.
xdmp.fromJSON(xdmp.unquote('["a", null, false]',null,"format-json")); => ["a", null, false]
var str = '[{"some-key":45683}, "this is a string", 123]'; var node = xdmp.unquote(str,null,"format-json"); xdmp.fromJSON(node); => [{"some-key":45683}, "this is a string", 123]