Function modifiers
cast
Commentary
added in 0.4.16
Casts a value to a target type. Supports casts to string, integer, double, and boolean.
Casts are strictly to/from string, meaning you can't perform lossy casts like double to/from integer. Use the decimals function modifier you need to manipulate the underlying values.
Examples
Cast to string
Use string to cast any value to a string.
{
    "_gen": "normalDistribution",
    "mean": 50,
    "sd": 2,
    "cast": "string"
}
[
    "47.14618903225951",
    "48.02212891795028",
    "52.18778620357622",
    "50.0926481089999",
    "47.828385657988"
]
Cast to integer
Use integer to parse a string to an integer.
{
    "_gen": "digitString",
    "n": 5,
    "cast": "integer"
}
[
    18638,
    33971,
    96772,
    96597,
    61852
]
Cast to double
Use double to parse a string to a double.
{
    "_gen": "constant",
    "x": "10.25",
    "cast": "double"
}
[
    10.25
]
Cast to boolean
Use boolean to parse a string to a boolean. Invalid values become false.
{
    "t": {
        "_gen": "constant",
        "x": "true",
        "cast": "boolean"
    },
    "f": {
        "_gen": "constant",
        "x": "false",
        "cast": "boolean"
    },
    "i": {
        "_gen": "constant",
        "x": "invalid",
        "cast": "boolean"
    }
}
[
    {
        "t": true,
        "f": false,
        "i": false
    }
]
Specification
JSON schema
{
    "type": "string",
    "enum": [
        "string",
        "integer",
        "double",
        "boolean"
    ]
}