Loading TOC...

MarkLogic 9 Product Documentation
json:array-values

json:array-values(
   $array as json:array,
   [$flatten as xs:boolean?]
) as item()*

Summary

Returns the array values as an XQuery sequence.

Parameters
array An array.
flatten Include values from subarrays in the sequence. The default is false, meaning that subarrays are returned as array values.

Example

xquery version "1.0-ml";

let $array :=
  json:array(
    <json:array xmlns:json="http://marklogic.com/xdmp/json"
                xmlns:xs="http://www.w3.org/2001/XMLSchema"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     <json:value xsi:type="xs:string">hello</json:value>
     <json:value xsi:type="xs:string">world</json:value>
     <json:array>
       <json:value xsi:type="xs:string">one</json:value>
       <json:value xsi:type="xs:string">two</json:value>
     </json:array>
    </json:array>
  )
return json:array-values($array)
=> ("hello", "world", ["one", "two"])

Example

xquery version "1.0-ml";

let $array :=
  json:array(
    <json:array xmlns:json="http://marklogic.com/xdmp/json"
                xmlns:xs="http://www.w3.org/2001/XMLSchema"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     <json:value xsi:type="xs:string">hello</json:value>
     <json:value xsi:type="xs:string">world</json:value>
     <json:array>
       <json:value xsi:type="xs:string">one</json:value>
       <json:value xsi:type="xs:string">two</json:value>
     </json:array>
    </json:array>
  )
return json:array-values($array, fn:true())
=> ("hello", "world", "one", "two")

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