Cast
Overview¶
Deprecated Block
This block is deprecated and will be moved to connection configuration in a future version. Type casting functionality will be handled automatically in connection configurations rather than requiring a separate block.
The Cast
Block converts an input into the specified type based on a provided schema. This is useful for ensuring that inputs conform to a specific structure or type.
Block Cast not found
Example(s)¶
Example 1: Cast a string to a number¶
- Create a
Cast
Block. - Set the schema to
{"type": "number"}
. - Provide the input:
"123"
. - The Block will output:
123
.
Example 2: Cast a JSON string to an object¶
- Set up a
Cast
Block. - Set the schema to
{"type": "object"}
. - Provide the input:
'{"name": "John"}'
. - The Block will output:
{"name": "John"}
.
Error Handling¶
- If the input cannot be cast to the specified type, the Block will raise a
ValueError
.
FAQ¶
What happens if the input doesn't match the schema?
The Block will raise an error or attempt to convert the input according to the schema.