Product SiteDocumentation Site

Chapter 5. Navigation in JSON content

5.1. Object lookup
5.2. Object key listing
5.3. Array lookup
5.4. Array unboxing
It is possible to navigate through JSON items using the dynamic function call syntax. The dynamic function call syntax is extended to handle object and array selection as follows:

5.1. Object lookup

If the dynamic function call is unary and the left-hand-side is an object, the semantics applied is that of object lookup and is as follows.
The unique parameter is cast to a string $s (an error is raised according to the semantics of casting if this fails).
If $s is in jdm:keys($o) then $o($s) returns the value of the pair with the name $s, i.e. jdm:value($o, $s). Otherwise (i.e., it has no key matching $s), an empty sequence is returned.
Example 5.1. Object lookup
Retrieving a Pair by its name:
        let $map := { "eyes" : "blue", "hair" : "fuchsia" }
        return $map("eyes")
Using Pairs from existing Objects to create a new Object:
        let $x := { "eyes" : "blue", "hair" : "fuchsia" }
        let $y := { "eyes" : brown, "hair" : "brown" }
        return { "eyes" : $x("eyes"), "hair" : $y("hair") }
          { "eyes" : "blue", "hair" : "brown" }