Loading TOC...

MarkLogic 9 Product Documentation
xdmp.toJSON

xdmp.toJSON(
   item as Sequence
) as Node

Summary

Constructs a JSON document.

Parameters
item A sequence of items from which the JSON document is to be constructed. A Sequence, typically containing a JavaScript Object, from which the JSON document is constructed. If you pass in a single value, it is treated as a Sequence with that single item; therefore, if you pass in an array, the array is treated as a single value (not as one value for each item in the array). If you mean to pass in the values of each item in the array, then you can call xdmp.arrayValues on the array.

Usage Notes

To serialize a JSON node to a string, use xdmp:quote.

Example

var object = {"a":111};
xdmp.toJSON(object)
=>
{"a":111}

Example

xdmp.toJSON({"foo":"bar"}).root.foo
=> "bar"

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