TUPLE

A set of key-value pair data whose value can be any of SpectX data types. The TUPLE object can be constructed using the STRUCTURE matcher when parsing source data.

LITERAL NOTATION: enclose data elements in curly braces separated by a comma:

{seq:1, name:'string', isMember:true}

Accessing TUPLE Elements

Data elements can be accessed by the key. Tuple t:{a:1, b:"text", c:{foo:2.3}} elements can be accessed:

t[a]        // => 1
t[b]        // => "text"
t[c][foo]   // => 2.3

Example

1
2
3
dual
| select(t:{a:1, b:"text", c:{foo:2.3}})
| select(t[a], t[b], t[c][foo]);
a b foo
1 text 2.3

Converting

TUPLE(VARIANT_OBJECT)
TUPLE(expr, ...)
  1. Converts VARIANT_OBJECT to TUPLE
  2. Converts one or more expressions returning any data type to TUPLE

Example:

1
dual | select(TUPLE(1,2.0,"foo"))
tuple
{f_0=1 f_1=2.0 f_2=”foo”}

Functions

t={a:1, b:"text", c:{foo:2.3}}

TUPLE_FIELD_SELECT(t, a)    // => 1

Parsing

1
2
3
STRUCTURE{matcher_expr, ...}:fieldname
JSON{matcher_expr, ...}:fieldname
$subpattern:fieldname