Chapter 8. Function library
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.
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) }
|}
};