Loading TOC...

json:subarray

json:subarray(
   array as json:array,
   startingLoc as xs:double,
   [length as xs:double]
) as json:array

Summary

Extract a subarray from an array, producing a new array. The second and third arguments to this function operate similarly to those of fn:subsequence for XQuery sequences.

Parameters
array An array.
startingLoc The starting position of the start of the subarray.
length The length of the subarray.

Example

  xdmp:to-json(json:subarray(json:to-array(1 to 6), 2, 4))
  => [2, 3, 4, 5]

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