Loading TOC...

MarkLogic Server 11.0 Product Documentation
json.transformToJsonObject

json.transformToJsonObject(
   node as Node,
   config as Object
) as Sequence

Summary

This function transforms an XML document to JSON and returns an object.

Parameters
node The node to transform. The node must be a node that was transformed from JSON (for example, as the result of a json:transform-from-json call with the basic strategy or from JSON that was loaded using the REST API).
config The configuration object representing the strategy.

Usage Notes

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.

See Also

Example

const json = require('/MarkLogic/json/json.xqy');

json.transformToJsonObject( xdmp.unquote('<root><key>value</key></root>'), json.config('full'))

/* The following JSON Object is produced:
{
  "root": {
    "_children": [
      {
        "key": { 
        "_children": ["value"]
        }
      }
    ]
  }
} */
   

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.