json:transform-to-json-object( $node as node(), $config as map:map ) as item()*
This function transforms an XML document to JSON and returns an object.
The supplied document (element or document node) is
transformed to JSON using the default (basic
) strategy
and returned as an object. The object will be either a
json:object
or json:array
.
When the default "basic" strategy is used, the XML node
must be in the http://marklogic.com/xdmp/json/basic
namespace.
xquery version '1.0-ml'; import module namespace json = "http://marklogic.com/xdmp/json" at "/MarkLogic/json/json.xqy"; json:transform-to-json-object( <root> <key>value</key> </root>, json:config("full")) => the following JSON object: json:object(<json:object xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:json="http://marklogic.com/xdmp/json"> <entry key="root"> <json:value> <json:object> <json:entry key="_children"> <json:value> <json:array> <json:value> <json:object> <json:entry key="key"> <json:value> <json:object> <json:entry key="_children"> <json:value> <json:array> <json:value xsi:type="xs:string">value</json:value> </json:array> </json:value> </json:entry> </json:object> </json:value> </json:entry> </json:object> </json:value> </json:array> </json:value> </json:entry> </json:object> </json:value> </entry> </json:object>)
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.