Construction Operators

Construction Operators

N1QL supports array and object construction operators.

Array construction

[ elements [, elements ]* ] 



Arrays are ordered lists with 0 or more values. These values can be one of the defined types. Arrays are enclosed in square brackets ([ ] ). Commas separate each value. For example: ["one", "two", "three"] and [1, 2, 3].

Object construction

{ members [ , members ]* }


string : expression

Objects contain name value members. Objects are enclosed in curly braces {}. Commas separate each pair (member). The colon (:) character separates the key or name from its value within each pair. All keys must be strings and should be distinct from each other within that object. The value can be any supported JSON data type.

Starting from version 4.5.1, you can use dynamic names in the name-value pairs. The names and values can both be arbitrary expressions. If a name does not evaluate to a string, the result of the object construction is NULL.
SELECT { UPPER("foo") : 1, "foo" || "bar" : 2 };
    "$1": {
      "FOO": 1,
      "foobar": 2
Note: Starting version 4.5.1, member names are optional when constructing dynamic objects.