json
JSON serializes the value to a JSON string.
JSON serializes the value to a JSON string. Pass 'pretty' as a parameter to produce indented output.
Input
any
Parameters
| # | Type | Required |
|---|---|---|
| 0 | string | no |
Returns
string
Examples
Serialize a map to compact JSON
Input
user = {"name": "Alice", "role": "admin"}Template
{{ user | json }}Output
{"name":"Alice","role":"admin"}Produce indented JSON for human reading
Input
config = {"region": "eu-west-1", "debug": false}Template
{{ config | json:'pretty' }}Output
{
"region": "eu-west-1",
"debug": false
}How is this guide?