docs/docs/en/template-print/syntax/formatters/array-formatting.md
Joins an array of strings or numbers into a single string.
Parameters:
,).index (can be negative to count from the end).['homer','bart','lisa']:arrayJoin() // Outputs "homer, bart, lisa"
['homer','bart','lisa']:arrayJoin(' | ') // Outputs "homer | bart | lisa"
['homer','bart','lisa']:arrayJoin('') // Outputs "homerbartlisa"
[10,50]:arrayJoin() // Outputs "10, 50"
[]:arrayJoin() // Outputs ""
null:arrayJoin() // Outputs null
{}:arrayJoin() // Outputs {}
20:arrayJoin() // Outputs 20
undefined:arrayJoin() // Outputs undefined
['homer','bart','lisa']:arrayJoin('', 1) // Outputs "bartlisa"
['homer','bart','lisa']:arrayJoin('', 1, 1) // Outputs "bart"
['homer','bart','lisa']:arrayJoin('', 1, 2) // Outputs "bartlisa"
['homer','bart','lisa']:arrayJoin('', 0, -1) // Outputs "homerbart"
The output is a string created by joining the array elements according to the specified parameters.
Transforms an array of objects into a string. It does not process nested objects or arrays.
Parameters:
, ).:).[{'id':2,'name':'homer'},{'id':3,'name':'bart'}]:arrayMap()
// Outputs "2:homer, 3:bart"
[{'id':2,'name':'homer'},{'id':3,'name':'bart'}]:arrayMap(' - ')
// Outputs "2:homer - 3:bart"
[{'id':2,'name':'homer'},{'id':3,'name':'bart'}]:arrayMap(' ; ', '|')
// Outputs "2|homer ; 3|bart"
[{'id':2,'name':'homer'},{'id':3,'name':'bart'}]:arrayMap(' ; ', '|', 'id')
// Outputs "2 ; 3"
[{'id':2,'name':'homer','obj':{'id':20},'arr':[12,23]}]:arrayMap()
// Outputs "2:homer"
['homer','bart','lisa']:arrayMap() // Outputs "homer, bart, lisa"
[10,50]:arrayMap() // Outputs "10, 50"
[]:arrayMap() // Outputs ""
null:arrayMap() // Outputs null
{}:arrayMap() // Outputs {}
20:arrayMap() // Outputs 20
undefined:arrayMap() // Outputs undefined
The output is a string generated by mapping and joining the array elements, ignoring nested object content.
Counts the row number in an array and outputs the current row number.
For example:
{d[i].id:count()}
Regardless of the value of id, it outputs the current row count.
Starting from v4.0.0, this formatter has been replaced internally by :cumCount.
Parameter:
In use, the output will display the row number according to the sequence of the array elements.