> For the complete documentation index, see [llms.txt](https://docs.fortifiedid.se/expressions/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.fortifiedid.se/expressions/typed-expansion.md).

# Typed expansion

By default, expansion always produces a string. A type directive converts the result to a specific type — necessary when a configuration property requires a non-string value such as a number, boolean, or JSON object.

## Syntax

```
@<type>:<value>
```

The value can be a literal or an expression:

```
@int:99
@boolean:${config.debug}
@json:${data.object}
```

## Supported types

<table><thead><tr><th width="181.109375">Directive</th><th>Result</th></tr></thead><tbody><tr><td><code>@string</code></td><td>String (default, same as no directive)</td></tr><tr><td><code>@int</code></td><td>Integer</td></tr><tr><td><code>@long</code></td><td>Large integer</td></tr><tr><td><code>@float</code></td><td>Decimal number</td></tr><tr><td><code>@double</code></td><td>Double-precision decimal</td></tr><tr><td><code>@number</code></td><td>Number — automatically selects integer or decimal type based on value</td></tr><tr><td><code>@bool</code></td><td>Boolean</td></tr><tr><td><code>@boolean</code></td><td>Boolean</td></tr><tr><td><code>@json</code></td><td>JSON object or array</td></tr><tr><td><code>@json-object</code></td><td>JSON object</td></tr><tr><td><code>@json-array</code></td><td>JSON array</td></tr></tbody></table>

## Behavior

**No directive** — value is treated as a string, including any `${...}` expressions:

```
${user.name}              →  "Alice"  (string)
@string:${user.name}      →  "Alice"  (same)
```

**Unknown directive** — if the directive is not recognised, the entire value is treated as a plain string without error:

```
@typo:99    →  "@typo:99"  (string, no error)
```

**Invalid conversion** — if the value cannot be converted to the specified type (e.g. `@int:hello`), an error is raised. For booleans, only `true` (case-insensitive) is true — all other values are false.

**JSON** — the value must be valid JSON. An invalid JSON string raises an error. Use `@json:` when the result may be either an object or an array; use `@json-object:` or `@json-array:` when the type is known.
