http://jsoniq.org/function-library

Description

Before using any of the functions below please remember to import the module namespace:

import module namespace libjn = "http://jsoniq.org/function-library";
This module provides the functions defined by the JSONiq specification, chapter 8 (Function Library). JSONiq extends the XQuery specification to also deal with JSON data natively.

Module code

Here is the actual XQuery module code.

Imported modules

See also

Authors

Ghislain Fourny

Version Declaration

jsoniq version "1.0" encoding "utf-8";

Namespaces

jnhttp://jsoniq.org/functions
libjnhttp://jsoniq.org/function-library
verhttp://zorba.io/options/versioning

Function Summary

accumulate($items as item()*) as object()

This function dynamically builds an object, like the {||} syntax, except that it does not throw an error upon pair collision.

descendant-arrays($items as item()*) as array()*

This function returns all arrays contained at any depth within a sequence of items.

descendant-arrays-priv($i as item()) as array()*

Helper function for libjn:descendant-arrays() .

descendant-objects($items as item()*) as object()*

This function returns all objects contained at any depth within a sequence of items.

descendant-objects-priv($i as item()) as object()*

Helper function for libjn:descendant-objects() .

descendant-pairs($items as item()*) as object()*

This function returns all pairs contained at any depth within an sequence of items.

descendant-pairs-priv($i as item()) as object()*

Helper function for libjn:descendant-pairs() .

intersect($items as item()*) as object()

This function returns the intersection of the objects contained in the given sequence of items, aggregating values corresponding to the same key into an array.

values($items as item()*) as item()*

This functions returns all values of all objects contained in a sequence of items.

Functions

accumulate#1

declare function libjn:accumulate(
    $items as item()*
) as object()

This function dynamically builds an object, like the {||} syntax, except that it does not throw an error upon pair collision. Instead, it accumulates them into an array, if more than one.

Parameters

  • $items

    A sequence of items, the objects of which are going to be accumulated into a single object.

Returns

  • object()

    The accumulated object.

descendant-arrays#1

declare function libjn:descendant-arrays(
    $items as item()*
) as array()*

This function returns all arrays contained at any depth within a sequence of items.

Parameters

  • $items

    A sequence of items.

Returns

  • array()*

    The descendant arrays of the input sequence.

descendant-arrays-priv#1

declare %:private function libjn:descendant-arrays-priv(
    $i as item()
) as array()*

Helper function for libjn:descendant-arrays()

Parameters

  • $i

    An item

Returns

  • array()*

    The descendant arrays of the item

descendant-objects#1

declare function libjn:descendant-objects(
    $items as item()*
) as object()*

This function returns all objects contained at any depth within a sequence of items.

Parameters

  • $items

    A sequence of items.

Returns

  • object()*

    The descendant objects of the input sequence.

descendant-objects-priv#1

declare %:private function libjn:descendant-objects-priv(
    $i as item()
) as object()*

Helper function for libjn:descendant-objects()

Parameters

  • $i

    An item

Returns

  • object()*

    The descendant objects of the item

descendant-pairs#1

declare function libjn:descendant-pairs(
    $items as item()*
) as object()*

This function returns all pairs contained at any depth within an sequence of items.

Parameters

  • $o

    An object.

Returns

  • object()*

    All direct and indirect descendant pairs.

descendant-pairs-priv#1

declare function libjn:descendant-pairs-priv(
    $i as item()
) as object()*

Helper function for libjn:descendant-pairs()

Parameters

  • $i

    An item

Returns

  • object()*

    The descendant pairs of the item

intersect#1

declare function libjn:intersect(
    $items as item()*
) as object()

This function returns the intersection of the objects contained in the given sequence of items, aggregating values corresponding to the same key into an array.

Parameters

  • $items

    A sequence of items.

Returns

  • object()

    The insersection of the objects contained in $items.

values#1

declare function libjn:values(
    $items as item()*
) as item()*

This functions returns all values of all objects contained in a sequence of items.

Parameters

  • $items

    A sequence of items.

Returns

  • item()*

    The values inside the objects of the sequence.