Expressions

String

4min
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 $string() https //docs jsonata org/string functions#string $length() https //docs jsonata org/string functions#length $substring() https //docs jsonata org/string functions#substring $substringbefore() https //docs jsonata org/string functions#substringbefore $substringafter() https //docs jsonata org/string functions#substringafter $uppercase() https //docs jsonata org/string functions#uppercase $lowercase() https //docs jsonata org/string functions#lowercase $trim() https //docs jsonata org/string functions#trim $pad() https //docs jsonata org/string functions#pad $contains() https //docs jsonata org/string functions#contains $split() https //docs jsonata org/string functions#split $join() https //docs jsonata org/string functions#join $match() https //docs jsonata org/string functions#match $replace() https //docs jsonata org/string functions#replace $eval() https //docs jsonata org/string functions#eval $base64encode() https //docs jsonata org/string functions#base64encode $base64decode() https //docs jsonata org/string functions#base64decode $encodeurlcomponent() https //docs jsonata org/string functions#encodeurlcomponent $encodeurl() https //docs jsonata org/string functions#encodeurl $decodeurlcomponent() https //docs jsonata org/string functions#decodeurlcomponent $decodeurl() https //docs jsonata org/string functions#decodeurl configuration result expression string concat expression =@ctx datasources mydata name & ' ' & @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 examples and code snippets string expressions this example shows how you can use various string functions to return data see the full code sample in github expression jigx datasources mydata type datasource static options data \ name jane stevens title doctor email jane\@first com 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 =@ctx datasources mydata name & ' ' & @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)