Product SiteDocumentation Site

6.9. jn:keys

This function returns all keys of all objects in the supplied sequence, using the jdm:keys accessor, with duplicates eliminated. The order in which the keys are returned is implementation-dependent but must be stable within a snapshot. Non-objects in the input sequence are ignored.
jn:keys($arg as item()*) as xs:string*
Example 6.6. Getting all keys in a sequence
          let $seq := ("foo", [ 1, 2, 3 ], { "a" : 1, "b" : 2 }, { "a" : 3, "c" : 4 })
          return jn:keys($seq)
Resulting (possibly with a different ordering) in:
          ("a", "b", "c")
Retrieving all Pairs from an Object:
Query:
            let $map := { "eyes" : "blue", "hair" : "fuchsia" }
            for $key in jn:keys($map)
            return { $key : $map($key) }
Result:
            { "eyes" : "blue" }
            { "hair" : "fuchsia" }