Loading TOC...


   [$items as item()*],
   [$limit as xs:double?],
   [$zero as item()?]
) as json:array


Constructs a json:array from a sequence of items.

items The items to be used as elements in the constructed array.
limit The size of the array to construct. If the size is less than the length of the item sequence, only as "limit" items are put into the array. If the size is more than the length of the sequence, the array is filled with null values up to the limit.
zero The value to use to pad out the array, if necessary. By default the empty sequence is used.

Usage Notes

Use this function to construct an in-memory object that represents a JSON array, suitable for use with xdmp:to-json. This function does not produce an array node. To construct an array node, use the array-node constructor.


xquery version "1.0-ml";

json:to-array(1 to 2)
    <json:array xmlns:json="http://marklogic.com/xdmp/json"
     <json:value xsi:type="xs:integer">1</json:value>
     <json:value xsi:type="xs:integer">2</json:value>

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