MarkLogic 10 Product Documentation
json:array-resize

json:array-resize(
   $array as json:array,
   $newSize as xs:unsignedLong,
   [$zero as item()?]
) as empty-sequence()

Summary

Resize the array to the new size. If the new size is greater than the old size, the new entries will be null. If the new size if smaller than the old size, the extra entries will be removed.

Parameters
array An array.
newSize New size.
zero The value to use to pad out the array, if necessary. By default the empty sequence is used.

Example

  let $a := json:to-array(1 to 3)
  let $_ := json:array-resize($a, 4)
  return xdmp:to-json($a)
  => [1, 2, 3, null]
Powered by MarkLogic Server | Terms of Use | Privacy Policy