Casting-functions

All cast-functions are statically bound to "core" -namespace.

number() <Number>

Number accepts input-types Number and String. If input is Number, then no conversion is required. If input is String, then this is converted into Number.

Example

number($precision) <Number>

Number with $precision-argument converts the input (Number or String) into Number with the amount of decimals decided by $precision.

Example

array() <Array>

Array converts Object input-type or Path into Array. Array takes each key-pair from Object and places them into an Array as its own item.

Example

Example

object() <Object>

Object without arguments converts an Array input-type into Object. The key-names are numbered strings starting from 1.

Example

object($groupBy) <Object>

Object with $groupBy-argument converts an Array input-type into an Object, with the key-names decided by the $groupBy-expression. The $groupBy-expression must return String or Array-value. See array:groupBy($by) for more details.

Example

string() <String>

String converts input-types into a String.

Example

string($options) <String>

String with $options-argument converts input-types into String. When converting an Array, the separator given in the "separator" -options is used. When converting a Raw-value, the "escape" -option may be used to decide whether to evaluate the escape-characters. If an Array item has a type other than String, Number, or Boolean, then these are skipped.

Example

raw() <Raw>

Raw converts input-types into a Raw.

Example

raw($options) <Raw>

Raw with $options-argument converts input-types into Raw. When converting an Array, the separator given in the "separator" -options is used. When converting a Raw-value, the "escape" -option may be used to decide whether to evaluate the escape-characters. This cast can be used also to cast Lambda into Raw-type. If an Array item has a type other than String, Number, or Boolean, then these are skipped.

Example

boolean() <Boolean>

Boolean converts String and Number values into Boolean value, according to following rules:

  • "true" (case insensitive) is converted into true
  • "false" (case insensitive) is converted into false
  • 1 is converted into true
  • 0 is converted into false

Example

Example

Example

Example