Arrays
sort, reverse, and distinct preserve the input type: sort(scores) on number[] infers number[].
For element-wise transformation and filtering, use the language constructs — -> projection and [predicate] filters — instead of JSONata's $map/$filter lambdas.
count(items: unknown[]): numberNumber of elements.
join(items: string[], separator?: string): stringConcatenates the strings with a separator (default `""`).
append(first: unknown[], second: unknown[]): unknown[]Concatenates two arrays.
zip(first: unknown[], second: unknown[]): unknown[][]Pairs elements by index, truncated to the shorter array.
sort(items: string[] | number[]): string[] | number[]Sorts in natural ascending order; the result keeps the input type.
reverse(items: unknown[]): unknown[]Reverses the order; the result keeps the input type.
shuffle(items: unknown[]): unknown[]Random permutation; keeps the input type.
distinct(items: unknown[]): unknown[]Removes duplicates (deep equality for objects); keeps the input type.
Measure
count
count(items: unknown[]): numberNumber of elements.
total: count(order.items)Combine
join
join(items: string[], separator?: string): stringConcatenates the strings with a separator (default "").
csv: join(user.tags, ", ")append
append(first: unknown[], second: unknown[]): unknown[]Concatenates two arrays.
all: append(data.names, data.scores)zip
zip(first: unknown[], second: unknown[]): unknown[][]Pairs elements by index, truncated to the shorter array.
paired: zip(data.names, data.scores)Reorder
sort
sort(items: string[] | number[]): string[] | number[]Sorts in natural ascending order; the result keeps the input type.
ranked: sort(data.scores)reverse
reverse(items: unknown[]): unknown[]Reverses the order; the result keeps the input type.
latestFirst: reverse(data.scores)shuffle
shuffle(items: unknown[]): unknown[]Random permutation; keeps the input type.
deckOrder: shuffle(deck.cards)Dedupe
distinct
distinct(items: unknown[]): unknown[]Removes duplicates (deep equality for objects); keeps the input type.
unique: distinct(data.names)Playground
{ "ranked": [ 12, 12, 7, 3 ], "unique": [ "ada", "alan" ], "merged": [ "ada", "alan", "ada", 12, 3, 12, 7 ], "paired": [ [ "ada", 12 ], [ "alan", 3 ], [ "ada", 12 ] ], "csv": "ada, alan, ada" }
{
ranked: number[];
unique: string[];
merged: (string | number)[];
paired: (string | number)[][];
csv: string;
}