Awee

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

#TypeRequired
0stringno

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?

On this page