Cast
Cast a variable or value to a specified type.
Type
data-ops.cast Block Data Operations
Folder
basic/data-opsChannels
Any
Pipe
Value
Scope
Any
Cast converts Value to Type and writes the result to the data pipe. Use it when a later block expects a different type than the one you already have (for example text from chat that must become a number).
If the conversion is not possible, the block fails (for example non-numeric text to Number, or text that is not a JSON object to Object).
Configure
| Setting | Description |
|---|---|
| Value | Literal or variable to convert (required) |
| Type | String, Number, Boolean, Array, or Object (required) |
Handles
| Handle | Role |
|---|---|
| In (target) | Incoming connection |
| Out (source) | Continues after the value is converted |
Pipe schema
The next block reads this on the data pipe (pipe.value). The type matches Type:
| Type | Result |
|---|---|
| String | Text |
| Number | Number. Empty text becomes 0. Yes/no becomes 1 or 0. Invalid text fails |
| Boolean | Yes/no. Text true, 1, yes, and on (any case) count as yes |
| Array | List. Already a list is unchanged. Missing becomes []. JSON text that is a list is parsed; other values become a one-item list |
| Object | Object. Already a non-list object is unchanged. JSON text must parse to an object or the block fails |