distinct
Get unique items from an array
Definition
array distinct(array $input)
Gets distinct items from $input
array based on token equality.
Parameters
array $input
Array to be checked for duplicates.
Returns
array
Array after removing the duplicates.
Examples
{
letters: distinct(['a', 'b', 'a']),
objects: distinct([{name: `"Joe"`, id: `1`}, {name: `"Joe"`, id: `1`}]),
zeros: distinct([`0.00`, `0.0`, `0`, `null`, `false`])
}
{
"letters": [
"a",
"b"
],
"objects": [
{
"name": "Joe",
"id": 1
}
],
"zeros": [
0.0,
null,
false
]
}
Remarks
Elements a
and b
are considered distinct if and only if a==b
evaluates to false
. Read more about equality in JMESPath.
Updated 7 months ago