json

The json filter encodes the value as a complete JSON string.

{{ data|json }}

Typically the value being encoded as a JSON string is usually an array or hash (associative array).

Assigning values

You can use the filter when assigning a value to a variable.

{% set var = data|json %}

< Back to the list of filters