Product SiteDocumentation Site

Chapter 8. Function library

8.1. libjn:accumulate
8.2. libjn:descendant-arrays
8.3. libjn:descendant-objects
8.4. libjn:descendant-pairs
8.5. libjn:flatten
8.6. libjn:intersect
8.7. libjn:project
8.8. libjn:remove-keys
8.9. libjn:values
This section defines a function library on top of JSONiq. These functions are not part of the JSONiq core, because the latter is intended to be minimal.

8.1. libjn:accumulate

This function dynamically builds an object, like jn:object, except that it does not throw an error upon pair collision. Instead, it accumulates them into an array. Non-object items in the input sequence are ignored.
declare function libjn:accumulate($sequence as item()*) as object()
{
  {|
    for $key in $sequence() return { $key : $sequence($key) }
  |}
};