Typed expansion

It is possible to type ("convert from string to specific type") the result of an expansion.

This is done by adding a type directive to the expansion expression:

"@type:${path.to.property}"

The following types are currently supported

  • string (default)

  • number

  • int

  • long

  • float

  • double

  • boolean (alias: bool)

  • json

The primary use of typed expansion is when adding the result of an expansion (always a string) to a scope (session for example) where it is to be consumed by a component that requires a specific type. If the consumer is type agnostic, typed expansion is not necessary. In this case the consumer will handle the typing.

If an invalid type directive is specified, type will default to string (just like regular expansion).

Examples

"@number:${scope.path.to.value}"  // "99" -> 99
"@int:${scope.path.to.value}"     // "99" -> 99
"@long:${scope.path.to.value}"    // "99" -> 99L
"@float:${scope.path.to.value}"   // "56.78" -> 56.78F
"@double:${scope.path.to.value}"  // "56.78" -> 56.78
"@boolean:${scope.path.to.value}" // "true" -> true
"@bool:${scope.path.to.value}"    // "false" -> false
"@json:${scope.path.to.value}"    // "{}" -> {}

Last updated