String
In JSONata String Functions, you can concat two strings to display multiple data records in one row, or write numbers as strings, or select only a few characters from the whole string, for example, to display a person's initials.
String functions
The string functions include:
Configuration
String concat expression
[email protected] & ' ' & @ctx.datasources.mydata.title
String length
=$length(@ctx.datasources.mydata.name)
Substring
=$substring(@ctx.datasources.mydata.name, 3, 5)
Substring before
=$substringBefore(@ctx.datasources.mydata.name, " ")
Substring after
=$substringAfter(@ctx.datasources.mydata.name, " ")
Upper case
=$uppercase(@ctx.datasources.mydata.name)
Lower case
=$lowercase(@ctx.datasources.mydata.name)
Evaluate PathsData
=$eval(@ctx.current.item.pathsData)
base64
"data:image/png;base64," & @ctx.datasources.mydata.data
String to number
($number(@ctx.datasources.tmra-graph.Total) >= 5) ($number(@ctx.datasources.tmra-graph.Total) < 8) ? true : false
Two-letter placeholder for avatar
=$uppercase($substring($substringBefore(@ctx.current.item.firstName, " "), 0, 1) & $substring($substringAfter(@ctx.current.item.lastName, " ") , 0, 1) )
Be careful when using complex expressions, such as expressions that iterate one datasource across another, as your solution performance could become slower. To avoid this, try to use the datasource queries to get the desired result rather than an expression.
Examples and code snippets

This example shows how you can use various string functions to return data.See the full code sample in GitHub.
datasources:
mydata:
type: datasource.static
options:
data:
- name: Jane Stevens
title: Doctor
email: [email protected]
number: 0.64734
number2: 12
color: blue
time: '2021-11-07T15:07:54.972Z'
children:
- type: component.entity
options:
children:
- type: component.entity-field
options:
label: String concat expression
value: [email protected] & ' ' & @ctx.datasources.mydata.title
- type: component.entity-field
options:
label: String length
value: =$length(@ctx.datasources.mydata.name)
- type: component.entity-field
options:
label: Substring
value: =$substring(@ctx.datasources.mydata.name, 3, 5)
- type: component.entity-field
options:
label: Substring before
value: =$substringBefore(@ctx.datasources.mydata.name, " ")
- type: component.entity-field
options:
label: Substring after
value: =$substringAfter(@ctx.datasources.mydata.name, " ")
- type: component.entity-field
options:
label: Upper case
value: =$uppercase(@ctx.datasources.mydata.name)
- type: component.entity-field
options:
label: Lower case
value: =$lowercase(@ctx.datasources.mydata.name)Last updated
Was this helpful?